Getting Started with Spring Boot on Mac
Follow these steps to install and set up Spring Boot CLI on your Mac:
Install Spring Boot CLI using Homebrew
Install Homebrew
If you don't have Homebrew installed, use the following command:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Verify Homebrew Installation
After installation, confirm that Homebrew is installed by running:
brew -v
This should display the version of Homebrew installed.
Update Homebrew
To ensure you have the latest Homebrew packages, run:
brew tap spring-io/tap
Install Spring Boot CLI
Now, install the Spring Boot CLI with Homebrew:
brew install spring-boot
Verify Installation
Homebrew installs Spring Boot CLI in /usr/local/bin. To confirm that Spring Boot CLI is installed correctly, check its version by running:
spring --version
Create a simple Spring Boot app
spring init --build maven mysimpleapp
Run the app
On Mac/Linux
./mvnw spring-boot:run
On PC
mvn spring-boot:run
Create a web app
spring init -dweb --build maven mywebapp
Create an index.html
in /src/main/resources/static
<html>
<head>
<title>Home</title>
</head>
<body>
Hello World!
</body>
</html>
Run the app
./mvnw spring-boot:run
Go to localhost:8080