Sring boot学习笔记(一)

本文介绍了如何使用IDEA构建Spring Boot项目,并详细说明了在pom.xml文件中配置依赖项的方法,特别是关于spring-boot-starter-tomcat依赖的正确处理方式,以及在不同打包方式下(如war包)如何调整配置。

1.使用ideal 构建并初始化spring boot项目时,应注意避免重复添加 **spring-boot-starter-tomcat **依赖

<dependencies>
 <dependency>
 <groupId>org.springframework.boot</groupId>
 <artifactId>spring-boot-starter-thymeleaf</artifactId>
 </dependency>
 <dependency>
 <groupId>org.springframework.boot</groupId>
 <artifactId>spring-boot-starter-web</artifactId>
 </dependency>

 <dependency>
 <groupId>org.springframework.boot</groupId>
 <artifactId>spring-boot-devtools</artifactId>
 <scope>runtime</scope>
 </dependency>
 <dependency>
 <groupId>org.springframework.boot</groupId>
 <artifactId>spring-boot-starter-test</artifactId>
 <scope>test</scope>
 </dependency>
</dependencies>

2.打包方式为“war”包时;

1)pom文件中得先声明打包方式为war

<packaging>war</packaging>

2)打包时,要将spring-boot-starter-tomcat的<scope>设置为provided,即不使用spring-boot内嵌tomcat;

<!--打包时,请释放注释provided-->
<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-tomcat</artifactId>
   <scope>provided</scope>
</dependency>

转载于:https://my.oschina.net/weijuer/blog/1457211

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值