SpringBoot使用maven构建
2024-08-30 00:14:00
1.使用maven作为parent管理
maven用户可以继承spring-boot-starter-parent项目获取合适的默认设置。该父项目提供一下特性:
- 默认编译级别为Java1.6
- 源编码格式为UTF-8
- 一个依赖管理节点,允许你省略普通依赖的标签,继承自Spring-boot-dependencies POM .
- 合适的资源过滤
- 合适的插件配置(exec插件,surefire,git commit ID,shade)
- 针对application.properties和application.yml的资源过滤
在项目的POM文件中添加parent配置
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
</dependencies>
如果需要生成一个可执行的jar,则添加配置
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
2.使用没有父POM的Spring Boot
如果不喜欢继承 spring-boot-starter-parent POM。 你可能需要使用公司标准parent, 或你可能倾向于显式声明所有Maven配置。如果你不使用 spring-boot-starter-parent , 通过使用一个 scope=import 的依赖, 你仍能获取到依赖管理的好处:
<dependencyManagement>
<dependencies>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>1.3.0.BUILD-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
改变Java的版本
spring-boot-starter-parent 选择相当保守的Java兼容策略。 如果你遵循我们的建议, 使用最新的Java版本, 你可以添加一个 java.version 属性
<properties>
<java.version>1.8</java.version>
</properties>
最新文章
- Java的几个同步辅助类
- 修改主机hostname
- EF架构~为BulkInsert引入SET IDENTITY_INSERT ON功能
- Windows Service 开发,安装与调试
- Android图片适配,drawable文件夹,低分辨率图片是否必要
- Spring For Android初体验
- CLSID {91493441-5A91-11CF-8700-00AA0060263B}错误
- 域名的a记录转过来他的公网ip
- Node.js tools for visual studio 在vs中使用Node.js
- 【Android】Android的优点和不足之处
- 排名最重要的三个优化阶段分析 --------------------->;>;转至(卧牛SEO/武汉SEO http://blog.sina.com.cn/zhengkangseo )
- SQL使用记录
- launch failed.Binary not found
- (转载)python日期函数
- 从性能角度看react组件拆分的重要性
- CREATE DATABASE RoomReservation
- SmartSql 快速使用指南
- CSS学习笔记_day1
- 如何使用@vue/cli 3.0在npm上创建,发布和使用你自己的Vue.js组件库
- Mybaits动态Sql
热门文章
- Atlassian官方合作伙伴
- Android MVP 构架初试
- Fireworks如何制作透明窗口PNG
- UVALive 4857 Halloween Costumes
- 解决Linux平台下VMware出现";No 3d support is available from the host";或";Hardware graphics acceleration is not available"; 错误
- poj 3311 Hie with the Pie dp+状压
- 算法笔记_018:旅行商问题(Java)
- react 调用项目中的 .html 文件
- couldn&#39;t find ";libstlport_shared.so";
- 2.4.1 用NPOI操作EXCEL关于HSSFClientAnchor(dx1,dy1,dx2,dy2,col1,row1,col2,row2)的参数