1. About Tomcat
Maybe it will find it strange. This is obviously a web program that runs, why is it not to start tomcat? But is it the main method of a Java class launched?
This is because the main method of the com.how2java.springboot.SpringbootApplication class embeds tomcat in, and there is no need to manually start tomcat.
2. About the plugin
First of all, developing Springboot applications in IDEA is the same as in Eclipse, which is essentially a maven project. However, IDEA itself comes with plug-ins that support SpringBoot. Unlike Eclipse, it also requires installation from a third party to use the plug-in, and it is very slow (foreign plug-in sources). Therefore, this knowledge point is developed using the SpringBoot plug-in that comes with IDEA.
3. Create a project
Menu -> New -> Project -> Spring Initializer and click Next
4. Project parameters
Enter the parameters in the two places shown in the figure, and no other parameters need to be modified, and then Next
5. Select the Web module
Then select Web on the left, just check Web on the right, and then click Next
6. Specify the path to the project
Specify the project path to e:/project/springboot (also available in other locations).
After this, the project is created successfully and you can see the project structure.
7. SpringbootApplication.java
After the project is created, it comes with a SpringbootApplication, which is marked by @SpringBootApplication, indicating that this is a Springboot application
8. HelloController.java
Create a new package com.how2java.springboot.web, and then create a new class HelloController under it.
This class is an ordinary controller in Spring MVC.
@RestController is a new annotation in spring4, and is the abbreviation of @ResponseBody and @Controller.
@RestController public class HelloController { @RequestMapping("/hello") public String hello() { return "Hello Spring Boot!"; } }9. Run and test
Next, run SpringbootApplication.java and access the address
1. http://127.0.0.1:8080/hello
You can see the test results
Summarize
The above is the Springboot project that I introduce to you to create a Springboot project that can run in IDEA. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support to Wulin.com website!