1.导入springboot父项目依赖(匹配版本号)
<!--继承springboot父项目-->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
</parent>
2.导入web启动器依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
3.配置文件
application.properties或application.yml
##服务器配置
server:
port: 9191
servlet:
path: /springboot
##logback
logging:
config: classpath:logback.xml
##spring mvc
spring:
mvc:
view:
prefix: /
suffix: .jsp
4.配置类
@SpringBootConfiguration:相当于xml
@Bean:相当于bean标签
@PropertySource:加载属性文件
5.主启动类
@SpringBootApplication:主启动类
@ComponentScan(basePackages):扫描
@ImportResource(value={“classpath:”})