MacOS Spring Boot Development Environment setup tutorial, macosspring
MacOS builds a Spring Boot development environment. The specific content is as follows:
Software and hardware environment
MacOS sisierra
Java 1.8.0 _ 65
Maven 3.5.0
Idea 2017.1.5
Preface
Recently, I have gained some knowledge about java web and learn about the recently popular development framework Spring Boot. From the perspective of a developer who has never been involved in java web and spring, spring boot is indeed a very good framework. It is easy to get started with simple configuration. It is a good starting point for children who want to enter java web.
Maven Installation
Select maven as the build tool. You can also use other tools, such as gradle. Download the latest stable version of the zip package from the apache site and decompress it to the specified directory. For example, here is/Users/djstava/Workshop/tools, and edit/Users/djstava /. bash_profile file, add a statement at the end of the file
export PATH=$PATH:/Users/djstava/Workshop/tools/apache-maven-3.5.0/bin
After the setting is complete, execute in Terminal
source ~/.bash_profile
After the preceding operations, check whether the setting result is correct and run the command on the terminal.
mvn -version
IDE Selection
Here I select IntelliJ IDEA of jetbrains. Of course you can also choose other products, such as eclipse.
Create the first application and create a project
Click Create New Project
Select Spring Initializer on the left and java 1.8 For the Project SDK.
Enter the basic information of some projects, select Maven Project for Type, and select Jar for Packaging. Others can be written at will.
Select Web as the dependency,
After the project is successfully created, the first build process will be slow. After the project is created, click the green button before the main function in DemoApplication. java to start the project.
Open the browser and enter localhost: 8080 to view
The browser output above is normal. Next, add the vertex Code so that it can display the vertex. Create a new java class
HelloController. java source code
package com.xugaoxiang;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;/** * Created by djstava on 15/07/2017. */@RestControllerpublic class HelloController { @RequestMapping("/hello") public String hello() { return "Hello Spring Boot!"; }}
Restart the project, view the browser, and enter the address localhost: 8080/hello
Engineering explanation
@ RestController and @ RequestMapping are two important annotations. @ RestController is responsible for processing http requests, and @ RequestMapping is responsible for url ing.
The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.