Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to build Spring Boot environment

Shulou Source: shulou.com Published: 2022-06-02 05:57:30 10月12日 Update

This article is to share with you about how to build a Spring Boot environment, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

First, create a simple Maven project

With Maven, you can automatically import packages that many programs depend on into your project by importing Spring Boot's starter module. With Maven's parent POM, it is also easier to manage dependent versions and use the default configuration, and modules in the project can easily inherit it. Add the following dependencies to pom.xml:

Org.springframework.boot spring-boot-starter-parent 1.5.8.RELEASE org.springframework.boot spring-boot-starter-web II. Create a SpringBoot application package com.lemon.springboot.example;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController / * @ author lemon * / @ SpringBootApplication@RestControllerpublic class Application {@ RequestMapping ("/") public String home () {return "hello";} public static void main (String [] args) {SpringApplication.run (Application.class, args);}}

This simple example is an entry to the SpringBoot application, or the main program, where @ SpringBootApplication is used to mark it as a SpringBoot application, and the main method makes it a main program, which will first execute the main method when the application starts, and then @ RestController indicates that the program is still a controller. If you visit the root directory of the project in the browser, it will return the string hello.

III. Start the project

Start the project, that is, run the main method, visit http://localhost:8080/ in the browser, and you will see that hello is displayed on the page. In fact, Tomcat is integrated in the dependency, and the server service is provided by Tomcat.

The above is how to build the Spring Boot environment, the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Tags: Project application method environment main program project more module browser knowledge program article service browsing utility that is entry character string instance Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Huawei Microsoft Shulou Tech Info Xiaomi