[JAVA] Try Spring Boot on Mac


Here are the steps to try out java Spring Boot on your local Mac. This time, I will summarize how to do it from the command line without using IDE etc.

What is Spring Boot?


Tomcat is included as a web server, and it is a framework that allows you to easily develop web applications with java. At present, Spring Boot seems to be the best framework for java.


macOS Sierra 10.12.3
Spring Boot 1.5.6
java 1.8.0_144


1. Java installation

Install from here. http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Or at the terminal

$ java -version

If you type, a dialog will appear if java is not included, so you can move to the java page by pressing "Detailed information". スクリーンショット 2017-09-05 22.26.13.png

Download here. スクリーンショット 2017-09-05 22.27.30.png

Check if it was installed.

$ java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)

2. Install Maven

Maven is a tool to download libraries. This time, I will use this to install Spring Boot.

Install Maven using brew.

$ brew update
$ brew install maven

Check if it was installed.

$ mvn --version
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-04T04:39:06+09:00)
Maven home: /usr/local/Cellar/maven/3.5.0/libexec
Java version: 1.8.0_144, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre
Default locale: ja_JP, platform encoding: UTF-8
OS name: "mac os x", version: "10.12.3", arch: "x86_64", family: "mac"

3. Project creation

Create a project with the following command.

$ mvn -B archetype:generate -DgroupId=edu.self -DartifactId=my_first_spring_boot -Dversion=1.0.0-SNAPSHOT -DarchetypeArtifactId=maven-archetype-quickstart
Various downloads start

$ cd my_first_spring_boot

4. Modify the configuration file

Modify the generated pom.xml as follows.


<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <!--Declare the use of Spring Boot and specify the version [Add]-->
    <!--Specify the use of Spring Boot Web application library [Addition]-->
    <!--Specify the use of Spring Boot unit test library [Addition]-->
<!--Delete JUnit specification (because it is included in Spring Boot) [Delete]
      <!--Maven plugin for building Spring Boot [Addition]-->
    <!--Java version specification [Addition]-->

5. Installation of required libraries

Install the library mentioned earlier. If you have already installed it, you can see the list of libraries.

$ mvn dependency:tree

6. Modify the application file

Modify the generated application file.


package my_first_spring_boot;

import java.util.concurrent.atomic.AtomicLong;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController //Specifying that the class accepts web application requests
@EnableAutoConfiguration //Automatically enable various settings
public class App {
    @RequestMapping("/") //Specifying the URL path
    public String index() {
        return "Hello Spring Boot!";

    public static void main(String[] args) {
      //This is the process for starting the application by Spring Boot.
      SpringApplication.run(App.class, args);

7. Start Spring Boot

Start with the following command.

$ mvn spring-boot:run

8. Access

If the build is successful, access it with a browser and check it. http://localhost:8080/

スクリーンショット 2017-09-05 23.27.16.png

That's it.


Recommended Posts

Try Spring Boot on Mac
Try running Spring Boot on Kubernetes
Spring Boot environment construction memo on mac
Try Spring Boot from 0 to 100.
Try using Spring Boot Security
gRPC on Spring Boot with grpc-spring-boot-starter
Try using Redmine on Mac docker
Create Spring Boot development environment on Vagrant
Challenge Spring Boot
Try using Spring Boot with VS Code
Try Spring Boot 1 (Environment construction ~ Tomcat startup)
Spring Boot Form
Spring Boot Memorandum
gae + spring boot
Put Java 11 and spring tool suite on mac
Try LDAP authentication with Spring Security (Spring Boot) + OpenLDAP
Try to implement login function with Spring Boot
Try to automate migration with Spring Boot Flyway
Deploy a Spring Boot application on Elastic Beanstalk
Install gradle on mac
SPRING BOOT learning record 01
Run STS4 on Mac
Spring Boot + Heroku Postgres
Try DisplayLink on Ubuntu 20.04
Install Java on Mac
Spring boot memo writing (1)
Try OpenLiteSpeed on CentOS8
First Spring Boot (DI)
SPRING BOOT learning record 02
Spring Boot2 cheat sheet
Spring Boot exception handling
Spring boot development-development environment-
Spring Boot learning procedure
Learning Spring Boot [Beginning]
Spring boot memo writing (2)
Spring Boot 2.2 Document Summary
[Spring Boot] DataSourceProperties $ DataSourceBeanCreationException
Try actions on GitHub [actions]
Install openjdk11 on mac
Spring Boot 2.3 Application Availability
Spring boot tutorials Topics
Install OpenJDK 8 on mac
Download with Spring Boot
Try using Spring JDBC
Try using DI container with Laravel and Spring Boot
Try using OpenID Connect with Keycloak (Spring Boot application)
Try Dependency Inversion Principle with Multiple Spring Boot Projects
Deploy the Spring Boot project to Tomcat on XAMPP
Try RabbitMQ + PHP on CentOS
[Spring Boot] Environment construction (macOS)
Set context-param in Spring Boot
Generate barcode with Spring Boot
Hello World with Spring Boot
Implement GraphQL with Spring Boot
Spring Boot tutorial task schedule
Spring 5 & Spring Boot 2 Hands-on preparation procedure
Get started with Spring boot
Try Docker on Windows 10 Home
Hello World with Spring Boot!
Spring Boot 2 multi-project in Gradle
[Spring Boot] Web application creation