Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How SpringBoot depends on the environment

Shulou Source: shulou.com Published: 2022-06-02 02:21:19 10月03日 Update

In view of how SpringBoot depends on the environment, this article introduces the corresponding analysis and answer in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.

one。 Prepare 1. Intellij IDEA2 before development. Jdk3. Maven II. Create the first springboot project 1. Create a project using Intellij IDEA

two。 Delete the following files

3. Change application.properties to application.yml (the attribute structure of yml file is more intuitive) server: port: 8888 # run port 4. Spring-boot-starter-web is introduced to depend on org.springframework.boot spring-boot-starter-web5. A hello world test Controller@RestControllerpublic class HelloController {@ RequestMapping ("/ hello") public String hello (String name) {return "hello world," + name;} 6. Test it

7. Project structure description

Directory location function src/main/java project java file storage location, initialization includes the main program entry XxxApplication, you can run this class directly to start the Spring Boot application src/main/resources to store static resources Src/main/resources/static such as pictures, CSS, JavaScript, web page template files are mainly used to store css, pictures, js and other development static files src/main/resources/public is used to store html files that can be directly used for access. Src/main/resources/templates is used to store web development template files src/test unit test code directory. Gitignoregit version management exclusion file target folder project code construction package result file location There is no need to maintain the pom.xmlmaven project configuration file application.properties (application.yml) for storing the configuration information of various dependent modules of the program, such as service port, database connection configuration and other questions about how SpringBoot depends on the environment. I hope the above content can be of some help to everyone, if you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.

Tags: File project location question development test configuration environment code picture more template directory port structure static help solution run easy Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info OPPO Reno Huawei Apple Shulou Information