SpringBoot微框架
用来简化Spring+Springmvc 初始化配置
内嵌Tomcat 无需部署war文件
引入依赖
org.springframework.boot
spring-boot-starter-parent
1.5.7.RELEASE
<dependencies>
<!--引入springboot的web支持-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
项目中src/main/resources/application,yml
@SpringBootApplication
在项目中如下的包结构中创建入口类 Application***
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class,args);
}
}
在application.yml
server:
port: 8989 #用来指定内嵌服务器端口号
context-path: /springboot #用来指定项目的访问路径
-
springboot中配置文件的拆分
#说明: 在实际开发过程中生产环境和测试环境有可能是不一样的 因此将生产中的配置和测试中的配置拆分开,是非常必要的在springboot中也提供了配置文件拆分的方式. 这里以生产中项名名称不一致为例:生产中项目名为: cmfz
测试中项目名为: springboot
端口同时为: 8080
拆分如下:
#主配置文件:
application.yml #用来书写相同的的配置
server:
port: 8080 #生产和测试为同一个端口
#生产配置文件:
application-pord.yml
server:
context-path: /cmfz
#测试配置文件:
application-dev.yml
server:
context-path: /springboot
引入jsp集成jar包
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
org.springframework.boot spring-boot-starter-tomcat org.apache.tomcat.embed tomcat-embed-jasper springboot_day1
org.springframework.boot spring-boot-maven-plugin