Springboot is equivalent to a practical tool framework. It integrates the three major frameworks of ssm and simplifies the development steps, eliminating the cumbersome environment setup and various spring configurations in ssm. In short , which is a very practical framework.
2.1 Import dependencies
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.9.RELEASE</version> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies>
2.2 Write the main program class
/** * @SpringBootApplication来标注一个主程序类 * 说明这是一个Springboot应用 */ @SpringBootApplication public class HelloWorldMainApplication { public static void main(String[] args) { // 让Springboot运行起来 SpringApplication.run(HelloWorldMainApplication.class,args); } }
2.3 Write the controller layer
@Controller public class HelloController { @RequestMapping("/hello") @ResponseBody public String hello() { return "hello"; } }
2.4 Run the main program Program
After the main program is started, enter http://localhost:8080/hello
2.5 Deployment project
Add a jar package plug-in to pom.xml, and then package it in the maven lifecycle. Then there will be a jar file in the target directory, copy it to the folder, and then use java -java xxx in the command window. The jar is deployed successfully.
<!-- 这个插件,可以将应用打包成一个可执行的jar包;--> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build>
##
The above is the detailed content of Springboot project deployment method. For more information, please follow other related articles on the PHP Chinese website!