Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Spring boot Learning 1-build and easy to use

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

The construction of spring boot is very simple.

First create the mavan project and create a startup class application (arbitrary class name) in the java directory, where the application file must be on the outermost layer, and spring boot will only scan the methods in the low-level files of application.

Use the SpringBootApplication annotation to identify the project startup class: Application {main (String [] args) {SpringApplication. (AccountApplication., args);}}

Then add dependencies:

Org.springframework.boot spring-boot-starter-web 1.3.5.RELEASE and controller layer: using @ Controller or @ RestController to specify controllerRestController annotations is equivalent to @ Controller+@ResponseBody. When using RestController, you only need to directly return the string to return the data to the front end. The method part still uses @ RequestMapping annotations such as @ Controller@RequestMapping (value= "/ test") public class test {@ ResponseBody @ RequestMapping (value= "/ hello"). Method = RequestMethod.GET) public String test () {System.out.print ("11111") Return "222222";}} is equivalent to @ RestController@RequestMapping (value= "/ test") public class test {@ RequestMapping (value= "/ hello", method = RequestMethod.GET) public String test () {System.out.print ("11111"); return "222222";}} the above spring boot is set up. Spring boot is embedded with tomcat. As long as you start the main method, the web end can access the methods in the project.

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report