引言
搭建一个J2EE的web项目,要经过一系列步骤,如配置maven,集成jar,配置xml代码,然后开发代码,打包, 部署,测试等,Spring意识到这些很繁琐,且机械化,有共通性,可以实现自动化,因此提出直接一站式、整体解决方案,简化快速地开发应用。
网址
https://spring.io/projects/spring-boot
https://spring.io/guides
本人学习教程也附录上 :http://www.chilangedu.com/course/1489582623.html#0
版本说明 springboot 1.5.9
1、Maven设置
参考
https://www.jianshu.com/p/d9b3843810ec
https://www.jianshu.com/p/6654e9fec93b
<profile>
<id>jdk-1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>
helloworld工程(IDEA工具开发)
1、pom文件
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>myproject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<!-- Inherit defaults from Spring Boot -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
</parent>
<!-- Add typical dependencies for a web application -->
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<!-- Package as an executable jar -->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
编写Application Controller 代码
略
打包
在pom文件中添加以下插件
<!-- 该插件可以将应用打包成一个可以执行的jar包-->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
部署
java -jar xxx.jar
springboot 场景启动器 starter
1、pom中的父项目
<parent>
<groupId>org.springframework.boot</groupId<