In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to create a SpringBoot project, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
Instructions before reading
Springboot needs maven or gradle for project management, and the editor then takes maven as an example. If you don't have the basics of maven, you can go to the maven tutorial to learn.
Create an empty springboot project
Go to the official website to create the website as follows:
Https://start.spring.io/
We choose maven project, language choice java,springboot version according to our own needs, editor here choose version 2.5.1. Fill in the project information according to your own situation, and select the packaging method you need and the corresponding java version (the above can be filled in according to your own needs).
It depends on us to choose spring web and devtools, and the addition of later dependencies can be managed through maven.
Click create, the site will generate a corresponding project archive, after the download is complete, unzipped can open an empty project.
If you have maven experience in creating a project, you can also use pom.xml to modify your project to become a springboot project (the following is the pom.xml corresponding to the above project, which can be modified by your own reference).
4.0.0 org.springframework.boot spring-boot-starter-parent 2.5.1 com.example W3Cschool 0.0.1-SNAPSHOT W3Cschool 618Last three days of return You sure you don't want to take a look? 11 org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-devtools. Runtime true org.springframework.boot spring-boot-starter-test test Org.springframework.boot spring-boot-maven-plugin creates HelloController
Create a new HelloController.java under the sibling folder of W3CschoolApplication.java, and enter the following code (code comments are as follows):
Import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;@RestController// note, the next code is a controller @ RequestMapping ("/ test") / / when the first-level path is / test, execute the following class public class HelloController {@ RequestMapping ("/ hello") / / execute the following method public String hello () {return "helloworld" when the secondary path is / hello / / return helloworld}} run
Springboot has a built-in Tomcat module, so it can run like java (it has a main () method), and run W3CschoolApplication.java to start the project.
After startup, you can visit http://localhost:8080/test/hello in the browser to see the running effect of the project.
Thank you for reading this article carefully. I hope the article "how to create a SpringBoot Project" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.