Maven 打包忽略依赖<scope></scope>

本文介绍了在Maven中如何在打包时忽略特定的依赖jar包,以减小最终jar的体积。通过在pom.xml文件中配置打包插件,可以创建包含和不包含依赖的两种jar包。使用<scope>provided</scope>可以确保编译时引入依赖,但在打包时不包含该依赖。在选择打包方式时,应根据实际运行环境是否有相关依赖来决定。

Maven 打包忽略依赖jar包之

1. 背景

  1. 作为事实上主流的jar包管理工具,有时候需要考虑工程打包是否包含所依赖jar包,这样可以缩减打出来的bar大小
  2. 实际maven打包,如果在pom文件中配置了打包插件,就会打出2个jar包,一个是包含依赖的jar包,一个是不包含依赖的jar包。
  3. 不包含依赖的jar包,体积会小很多,只包含编写的逻辑代码,但要求这个jar包运行环境中必须有这些依赖jar包。
  4. 包含依赖的jar包,只要有jre 运行环境,就可以运行,因为已经把所依赖的jar包都打进去了,对外部没有依赖。但体积会相应大很多。
    在这里插入图片描述
    在这里插入图片描述

这里可以看出,original开头的是原始包,也就是不包含依赖jar包的工程包。

  1. 所以,2种打包方式都存在,但需要根据情况进行选择。在很多情况下,为了追求jar包体积精简,有时候就会采取不带依赖进行打包。
  2. maven其实也提供了针对单个jar包是否打进工程包中的选项

2. 如何处理

<dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-core_2.12</artifactId>
            <version>${spark.version}</version>
            <!-- 编译时会引入依赖,打包是不引入依赖 -->
           <scope>provided</scope>
        </dependency>

上述配置中,provided加上这一个配置项,编译时会引入这个依赖,但打包是不会依赖。
这样就可以保证编译时不会因为找不到jar包而报错,但打出来的jar包就不会引入这个jar包,就可以针对单个jar包粒度做是否打进工程包做控制。

注意,如果无法保证工程打出来的包中运行环境是否包含所依赖jar,建议最好都打成依赖包,先解决是否可以跑起来的问题,如有必要再考虑jar包体积大的问题。

pom报错 !Dependency ' org. springframework. boot: spring-boot-starter异nc:' not found :109 !Dependency ' org. springframework. boot: spring-boot-starterasync:' not found :109 !Dependency ' org. modelMapper: modelMapper:3.1.1' not found :146 !Dependency ' org. modelMapper: modelMapper:3.1.1' not found :146 !Dependency ' org. modelMapper: modelMapper:3.1.1' not found :147 !Dependency ' org. modelMapper: modelMapper:3.1.1' not found :147 !Dependency ' org. modelMapper: modelMapper:3.1.1' not found :148 !Dependency ' org. modelMapper: modelMapper:3.1.1' not found :148 !Dependency ' cn. hutool: hutool-all:5.8.20' not found :153 !Dependency ' cn. hutool: hutool-all:5.8.20' not found :153 !Dependency ' cn. hutool: hutool-all:5.8.20' not found :154 !Dependency ' cn. hutool: hutool-all:5.8.20' not found :154 !Dependency ' cn. hutool: hutool-all:5.8.20' not found :155 !Dependency ' cn. hutool: hutool-all:5.8.20' not found :155 !Dependency ' commonsfileupload: commonsfileupload:1.5' not found :167 !Dependency ' commonsfileupload: commonsfileupload:1.5' not found :167 !Dependency ' commonsfileupload: commonsfileupload:1.5' not found :168 !Dependency ' commonsfileupload: commonsfileupload:1.5' not found :168 !Dependency ' commonsfileupload: commonsfileupload:1.5' not found :169 !Dependency ' commonsfileupload: commonsfileupload:1.5' not found :169 !Dependency ' com. google. guava: guava:31.1-jre' not found :176 !Dependency ' com. google. guava: guava:31.1-jre' not found :176 !Dependency ' org. apache. poi: po i:5.2.3' not found :182 !Dependency ' org. apache. po i:5.2.3' not found :182 Dependency'org.apache.poipoi:5.2.3'not found:183 Dependency'org.apache.poipoi:5.2.3'not found:183 Dependency'org.apache.poipoi:5.2.3'not found:184 Dependency'org.apache.poipoi:5.2.3'not found:184 Dependency'org.apache.poipoi-ooxml:5.2.3'not found:187 Dependency'org.apache.poipoi-ooxml:5.2.3'not found:187 Dependency'org.apache.poipoi-ooxml:5.2.3'not found:188 Dependency'org.apache.poipoi-ooxml:5.2.3'not found:188 Dependency'org.apache.poipoi-ooxml:5.2.3'not found:189 Dependency'org.apache.poipoi-ooxml:5.2.3'not found:189 Dependency'com.itextpdf.itextpdf:5.5.13.3'not found:194 Dependency'com.itextpdf.itextpdf:5.5.13.3'not found:194 Dependency'com.itextpdf.itextpdf:5.5.13.3'not found:195 Dependency'com.itextpdf.itextpdf:5.5.13.3'not found:195 Dependency'com.itextpdf.itextpdf:5.5.13.3'not found:196 Dependency'com.itextpdf.itextpdf:5.5.13.3'not found:196 Dependency'io.jsonwebtoken:jjwtapi:0.11.5'not found:202 Dependency'io.jsonwebtoken:jjwtapi:0.11.5'not found:202 Dependency'io.jsonwebtoken:jjwtapi:0.11.5'not found:203 Dependency'io.jsonwebtoken:jjwtapi:0.11.5'not found:203 Dependency'io.jsonwebtoken:jjwtapi:0.11.5'not found:204 Dependency'io.jsonwebtoken:jjwtapi:0.11.5'not found:204 Dependency'io.jsonwebtoken:jjwtimpl:0.11.5'not found:207 Dependency'io.jsonwebtoken:jjwtimpl:0.11.5'not found:207 !Dependency'io.jsonwebtoken:jjwt-impl:0.11.5'not found:209 !Dependency'io.jsonwebtoken:jjwt-impl:0.11.5'not found:209 !Dependency'io.jsonwebtoken:jjwt-jackson:0.11.5'not found:213 !Dependency'io.jsonwebtoken:jjwt-jackson:0.11.5'not found:213 !Dependency'io.jsonwebtoken:jjwt-jackson:0.11.5'not found:214 !Dependency'io.jsonwebtoken:jjwt-jackson:0.11.5'not found:214 !Dependency'io.jsonwebtoken:jjwt-jackson:0.11.5'not found:215 !Dependency'io.jsonwebtoken:jjwt-jackson:0.11.5'not found:215 !Dependency'org.springdoc:springdoc-openapi-uì:3.0.0'not found:222 !Dependency'org.springdoc:springdoc-openapi-uì:3.0.0'not found:222 !Dependency'org.springdoc:springdoc-openapi-uì:3.0.0'not found:223 !Dependency'org.springdoc:springdoc-openapi-uì:3.0.0'not found:223 !Dependency'org.springdoc:springdoc-openapi-uì:3.0.0'not found:224 !Dependency'org.springdoc:springdoc-openapi-uì:3.0.0'not found:224 !Dependency'com.github.ben-manes.caffeine:caffeine:3.1.6'not found:230 !Dependency'com.github.ben-manes.caffeine:caffeine:3.1.6'not found:230 !Dependency'com.github.ben-manes.caffeine:caffeine:3.1.6'not found:231 !Dependency'com.github.ben-manes.caffeine:caffeine:3.1.6'not found:231 !Dependency'com.github.ben-manes.caffeine:caffeine:3.1.6'not found:232 !Dependency'com.github.ben-manes.caffeine:caffeine:3.1.6'not found:232 !Dependency'org.webjars:jQuery:3.6.0'not found:260 !Dependency'org.webjars:jQuery:3.6.0'not found:260 !Dependency'org.webjars:font awesome:6.1.1'not found:266 !Dependency'org.webjars:font awesome:6.1.1'not found:266 !Dependency'org.webjars:font awesome:6.1.1'not found:267 !Dependency 'org.webjars:charts:3.7.1' not found:273 !Dependency 'org.webjars:charts:3.7.1' not found:274 !Dependency 'org.webjars:charts:3.7.1' not found:274 !Dependency 'org.webjars:webjars-位置-core:0.50' not found:281 !Dependency 'org.webjars:webjars-位置-core:0.50' not found:281 !Plugin 'org.eclipse.m2e:lifecycle-mapping:1.0.0' not found:576 !Plugin 'org.eclipse.m2e:lifecycle-mapping:1.0.0' not found:577 !Plugin 'org.eclipse.m2e:lifecycle-mapping:1.0.0' not found:578 !Dependency 'io.gatling.highcharts:gatling-charts-highcharts:3.9.5' not found:722 !Dependency 'io.gatling.highcharts:gatling-charts-highcharts:3.9.5' not found:722 !Dependency 'io.gatling.highcharts:gatling-charts-highcharts:3.9.5' not found:723 !Dependency 'io.gatling.highcharts:gatling-charts-highcharts:3.9.5' not found:723 !Dependency 'io.gatling.highcharts:gatling-charts-highcharts:3.9.5' not found:724 !Dependency 'io.gatling.highcharts:gatling-charts-highcharts:3.9.5' not found:724 !Plugin 'org.sonarsource.scanner.maven:sonar-maven插in:3.9.1.2184' not found:772 !Plugin 'org.sonarsource.scanner.maven:sonar-maven插in:3.9.1.2184' not found:772 !Plugin 'org.sonarsource.scanner.maven:sonar-maven插in:3.9.1.2184' not found:773 !Plugin 'org.sonarsource.scanner.maven:sonar-maven插in:3.9.1.2184' not found:773 !Plugin 'org.sonarsource.scanner.maven:sonar-maven插in:3.9.1.2184' not found:774 !Plugin 'org.sonarsource.scanner.maven:sonar-maven插in:3.9.1.2184' not found:774 !Cannot resolve symbol ' sonar':779 !Plugin 'com.github.spotbugs:spotbugs-maven插in:4.7.3.0' not found:787 !Plugin 'com.github.spotbugs:spotbugs-maven插in:4.7.3.0' not found:787 !Plugin 'com.github.spotbugs:spotbugs-maven插in:4.7.3.0' not found:788 !Plugin 'com.github.spotbugs:spotbugs-maven插in:4.7.3.0' not found:788 Plugin'com.github.spotbugs:spotbugs-maven插in:4.7.3.0'not found:789 Plugin'com.github.spotbugs:spotbugs-maven插in:4.7.3.0'not found:789 Cannot resolve symbol ' check':799 Plugin'org.apache.maven. plugins:maven-checkstyle插in:3.2.0'not found:808 Plugin'org.apache.maven. plugins:maven-checkstyle插in:3.2.0'not found:808 Plugin'org.apache.maven. plugins:maven-checkstyle插in:3.2.0'not found:809 Plugin'org.apache.maven. plugins:maven-checkstyle插in:3.2.0'not found:809 Cannot resolve symbol ' check':820 Plugin'org.apache.maven. plugins:maven-pmd插in:3.19.0'not found:829 Plugin'org.apache.maven. plugins:maven-pmd插in:3.19.0'not found:829 Plugin'org.apache.maven. plugins:maven-pmd插in:3.19.0'not found:830 Plugin'org.apache.maven. plugins:maven-pmd插in:3.19.0'not found:830 Cannot resolve symbol ' check':841 Plugin'org.apache.maven. plugins:maven-surefire-report插in:2.22.2'not found:964 Plugin'org.apache.maven. plugins:maven-surefire-report插in:2.22.2'not found:964 Plugin'org.apache.maven. plugins:maven-surefire-report插in:2.22.2'not found:965 Plugin'org.apache.maven. plugins:maven-surefire-report插in:2.22.2'not found:965 Plugin'org.apache.maven. plugins:maven-pmd插in:3.19.0'not found:971 Plugin'org.apache.maven. plugins:maven-pmd插in:3.19.0'not found:971 Plugin'org.apache.maven. plugins:maven-pmd插in:3.19.0'not found:972 Plugin'org.apache.maven. plugins:maven-pmd插in:3.19.0'not found:972 Plugin'org.apache.maven. plugins:maven-checkstyle插in:3.2.0'not found:983 Plugin'org.apache.maven. plugins:maven-checkstyle插in:3.2.0'not found:983 Plugin'org.apache.maven. plugins:maven-checkstyle插in:3.2.0'not found:984 Plugin' org. apache. maven. plugins: maven-checkstyle插in:3.2.0' not found:984 Plugin' com. github. spotbugs: spotbugs-maven插in:4.7.3.0' not found:993 Plugin' com. github. spotbugs: spotbugs-maven插in:4.7.3.0' not found:993 Plugin' com. github. spotbugs: spotbugs-maven插in:4.7.3.0' not found:994 Plugin' com. github. spotbugs: spotbugs-maven插in:4.7.3.0' not found:994 Plugin' com. github. spotbugs: spotbugs-maven插in:4.7.3.0' not found:995 Plugin' com. github. spotbugs: spotbugs-maven插in:4.7.3.0' not found:995 修复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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <!-- Spring Boot 父项目 --> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.7.14</version> <relativePath/> </parent> <groupId>com.drivingschool</groupId> <artifactId>driving-school-system</artifactId> <version>2.0.0</version> <name>driving-school-system</name> <description>驾校学员管理系统</description> <properties> <!-- Java版本 --> <java.version>11</java.version> <maven.compiler.source>11</maven.compiler.source> <maven.compiler.target>11</maven.compiler.target> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <!-- 依赖版本 --> <mysql.version>8.0.33</mysql.version> <h2.version>2.1.214</h2.version> <lombok.version>1.18.28</lombok.version> <modelmapper.version>3.1.1</modelmapper.version> <hutool.version>5.8.20</hutool.version> <poi.version>5.2.3</poi.version> <itextpdf.version>5.5.13.3</itextpdf.version> <javax.mail.version>1.6.2</javax.mail.version> <jakarta.validation.version>3.0.2</jakarta.validation.version> <swagger.version>3.0.0</swagger.version> <jjwt.version>0.11.5</jjwt.version> <logback.version>1.2.12</logback.version> <commons-io.version>2.11.0</commons-io.version> <commons-fileupload.version>1.5</commons-fileupload.version> <caffeine.version>3.1.6</caffeine.version> <guava.version>31.1-jre</guava.version> <slf4j.version>1.7.36</slf4j.version> </properties> <dependencies> <!-- ========== Spring Boot Starters ========== --> <!-- Web支持 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!-- Spring Security安全框架 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <!-- Thymeleaf模板引擎 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> <!-- Thymeleaf与Spring Security整合 --> <dependency> <groupId>org.thymeleaf.extras</groupId> <artifactId>thymeleaf-extras-springsecurity5</artifactId> </dependency> <!-- JPA数据持久化 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <!-- 数据验证 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-validation</artifactId> </dependency> <!-- 邮件支持 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-mail</artifactId> </dependency> <!-- 缓存支持 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-cache</artifactId> </dependency> <!-- AOP支持 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-aop</artifactId> </dependency> <!-- 异步处理 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-async</artifactId> </dependency> <!-- ========== 数据库相关 ========== --> <!-- MySQL驱动 --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>${mysql.version}</version> <scope>runtime</scope> </dependency> <!-- H2数据库(开发测试用) --> <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <version>${h2.version}</version> <scope>runtime</scope> </dependency> <!-- 数据库连接池 --> <dependency> <groupId>com.zaxxer</groupId> <artifactId>HikariCP</artifactId> </dependency> <!-- ========== 工具库 ========== --> <!-- Lombok代码简化 --> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>${lombok.version}</version> <optional>true</optional> </dependency> <!-- ModelMapper对象映射 --> <dependency> <groupId>org.modelmapper</groupId> <artifactId>modelmapper</artifactId> <version>${modelmapper.version}</version> </dependency> <!-- Hutool工具包 --> <dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> <version>${hutool.version}</version> </dependency> <!-- Apache Commons IO --> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>${commons-io.version}</version> </dependency> <!-- Apache Commons FileUpload --> <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>${commons-fileupload.version}</version> </dependency> <!-- Guava工具库 --> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>${guava.version}</version> </dependency> <!-- ========== 数据处理 ========== --> <!-- Apache POI Excel处理 --> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>${poi.version}</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>${poi.version}</version> </dependency> <!-- iText PDF生成 --> <dependency> <groupId>com.itextpdf</groupId> <artifactId>itextpdf</artifactId> <version>${itextpdf.version}</version> </dependency> <!-- ========== 安全与认证 ========== --> <!-- JWT令牌 --> <dependency> <groupId>io.jsonwebtoken</groupId> <artifactId>jjwt-api</artifactId> <version>${jjwt.version}</version> </dependency> <dependency> <groupId>io.jsonwebtoken</groupId> <artifactId>jjwt-impl</artifactId> <version>${jjwt.version}</version> <scope>runtime</scope> </dependency> <dependency> <groupId>io.jsonwebtoken</groupId> <artifactId>jjwt-jackson</artifactId> <version>${jjwt.version}</version> <scope>runtime</scope> </dependency> <!-- ========== API文档 ========== --> <!-- SpringDoc OpenAPI --> <dependency> <groupId>org.springdoc</groupId> <artifactId>springdoc-openapi-ui</artifactId> <version>${swagger.version}</version> </dependency> <!-- ========== 缓存 ========== --> <!-- Caffeine缓存 --> <dependency> <groupId>com.github.ben-manes.caffeine</groupId> <artifactId>caffeine</artifactId> <version>${caffeine.version}</version> </dependency> <!-- ========== 日志 ========== --> <!-- SLF4J日志门面 --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>${slf4j.version}</version> </dependency> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>${logback.version}</version> </dependency> <!-- ========== 前端依赖 ========== --> <!-- Bootstrap WebJar --> <dependency> <groupId>org.webjars</groupId> <artifactId>bootstrap</artifactId> <version>5.1.3</version> </dependency> <!-- jQuery WebJar --> <dependency> <groupId>org.webjars</groupId> <artifactId>jquery</artifactId> <version>3.6.0</version> </dependency> <!-- Font Awesome WebJar --> <dependency> <groupId>org.webjars</groupId> <artifactId>font-awesome</artifactId> <version>6.1.1</version> </dependency> <!-- Chart.js WebJar --> <dependency> <groupId>org.webjars</groupId> <artifactId>chartjs</artifactId> <version>3.7.1</version> </dependency> <!-- WebJars Locator --> <dependency> <groupId>org.webjars</groupId> <artifactId>webjars-locator-core</artifactId> <version>0.50</version> </dependency> <!-- ========== 测试依赖 ========== --> <!-- Spring Boot测试 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <!-- Spring Security测试 --> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-test</artifactId> <scope>test</scope> </dependency> <!-- JUnit 5 --> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-api</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-engine</artifactId> <scope>test</scope> </dependency> <!-- Mockito测试框架 --> <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-core</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-junit-jupiter</artifactId> <scope>test</scope> </dependency> <!-- 测试数据库 --> <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <version>${h2.version}</version> <scope>test</scope> </dependency> <!-- ========== 开发工具 ========== --> <!-- Spring Boot开发工具(热部署) --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> <optional>true</optional> </dependency> <!-- ========== 其他 ========== --> <!-- Java Mail API --> <dependency> <groupId>com.sun.mail</groupId> <artifactId>javax.mail</artifactId> <version>${javax.mail.version}</version> </dependency> <!-- Jakarta Validation API --> <dependency> <groupId>jakarta.validation</groupId> <artifactId>jakarta.validation-api</artifactId> <version>${jakarta.validation.version}</version> </dependency> <!-- Servlet API --> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <scope>provided</scope> </dependency> </dependencies> <build> <!-- 资源过滤配置 --> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> <includes> <include>**/*.properties</include> <include>**/*.yml</include> <include>**/*.xml</include> <include>**/*.sql</include> </includes> </resource> <resource> <directory>src/main/resources</directory> <filtering>false</filtering> <excludes> <exclude>**/*.properties</exclude> <exclude>**/*.yml</exclude> <exclude>**/*.xml</exclude> <exclude>**/*.sql</exclude> </excludes> </resource> </resources> <plugins> <!-- Spring Boot Maven插件 --> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <excludes> <exclude> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </exclude> </excludes> <!-- 指定主类 --> <mainClass>com.drivingschool.DrivingSchoolApplication</mainClass> <!-- 构建可执行JAR --> <layout>JAR</layout> <!-- 包含所有依赖 --> <includes> <include> <groupId>non-exists</groupId> <artifactId>non-exists</artifactId> </include> </includes> </configuration> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> <!-- Maven编译插件 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.10.1</version> <configuration> <source>${java.version}</source> <target>${java.version}</target> <encoding>UTF-8</encoding> <annotationProcessorPaths> <path> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>${lombok.version}</version> </path> </annotationProcessorPaths> </configuration> </plugin> <!-- 资源处理插件 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>3.3.0</version> <configuration> <encoding>UTF-8</encoding> </configuration> </plugin> <!-- 测试插件 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.2</version> <configuration> <skipTests>false</skipTests> <includes> <include>**/*Test.java</include> <include>**/*Tests.java</include> </includes> <excludes> <exclude>**/*IntegrationTest.java</exclude> </excludes> </configuration> </plugin> <!-- JaCoCo测试覆盖率插件 --> <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>0.8.8</version> <executions> <execution> <goals> <goal>prepare-agent</goal> </goals> </execution> <execution> <id>report</id> <phase>test</phase> <goals> <goal>report</goal> </goals> </execution> </executions> <configuration> <excludes> <exclude>**/model/*</exclude> <exclude>**/dto/*</exclude> <exclude>**/config/*</exclude> <exclude>**/DrivingSchoolApplication.class</exclude> </excludes> </configuration> </plugin> <!-- Docker构建插件(可选) --> <plugin> <groupId>com.spotify</groupId> <artifactId>dockerfile-maven-plugin</artifactId> <version>1.4.13</version> <executions> <execution> <id>default</id> <goals> <goal>build</goal> </goals> </execution> <execution> <id>tag</id> <goals> <goal>tag</goal> </goals> <configuration> <tag>${project.version}</tag> </configuration> </execution> <execution> <id>push</id> <goals> <goal>push</goal> </goals> <configuration> <tag>${project.version}</tag> </configuration> </execution> </executions> <configuration> <repository>drivingschool/${project.artifactId}</repository> <tag>${project.version}</tag> <buildArgs> <JAR_FILE>${project.build.finalName}.jar</JAR_FILE> </buildArgs> </configuration> </plugin> <!-- 源码打包插件 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <version>3.2.1</version> <executions> <execution> <id>attach-sources</id> <goals> <goal>jar-no-fork</goal> </goals> </execution> </executions> </plugin> <!-- Javadoc插件 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <version>3.4.1</version> <executions> <execution> <id>attach-javadocs</id> <goals> <goal>jar</goal> </goals> </execution> </executions> <configuration> <encoding>UTF-8</encoding> <docencoding>UTF-8</docencoding> <charset>UTF-8</charset> </configuration> </plugin> </plugins> <!-- 插件管理 --> <pluginManagement> <plugins> <plugin> <groupId>org.eclipse.m2e</groupId> <artifactId>lifecycle-mapping</artifactId> <version>1.0.0</version> <configuration> <lifecycleMappingMetadata> <pluginExecutions> <pluginExecution> <pluginExecutionFilter> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <versionRange>[0.8.6,)</versionRange> <goals> <goal>prepare-agent</goal> </goals> </pluginExecutionFilter> <action> <ignore/> </action> </pluginExecution> </pluginExecutions> </lifecycleMappingMetadata> </configuration> </plugin> </plugins> </pluginManagement> </build> <!-- 依赖管理 --> <dependencyManagement> <dependencies> <!-- Spring Cloud依赖管理(可选,用于微服务扩展) --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>2021.0.8</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <!-- 项目信息 --> <organization> <name>Driving School Management</name> <url>https://www.drivingschool.com</url> </organization> <!-- 开发者信息 --> <developers> <developer> <id>developer1</id> <name>张三</name> <email>zhangsan@example.com</email> <organization>驾校管理系统开发组</organization> <roles> <role>架构师</role> <role>开发工程师</role> </roles> <timezone>+8</timezone> </developer> <developer> <id>developer2</id> <name>李四</name> <email>lisi@example.com</email> <organization>驾校管理系统开发组</organization> <roles> <role>后端开发工程师</role> </roles> <timezone>+8</timezone> </developer> </developers> <!-- 许可证信息 --> <licenses> <license> <name>Apache License, Version 2.0</name> <url>https://www.apache.org/licenses/LICENSE-2.0</url> <distribution>repo</distribution> </license> </licenses> <!-- 版本控制系统 --> <scm> <connection>scm:git:https://github.com/yourusername/driving-school-system.git</connection> <developerConnection>scm:git:https://github.com/yourusername/driving-school-system.git</developerConnection> <url>https://github.com/yourusername/driving-school-system</url> <tag>v${project.version}</tag> </scm> <!-- 问题追踪 --> <issueManagement> <system>GitHub Issues</system> <url>https://github.com/yourusername/driving-school-system/issues</url> </issueManagement> <!-- 持续集成 --> <ciManagement> <system>GitHub Actions</system> <url>https://github.com/yourusername/driving-school-system/actions</url> </ciManagement> <!-- 多环境配置 --> <profiles> <!-- 开发环境 --> <profile> <id>dev</id> <properties> <spring.profiles.active>dev</spring.profiles.active> <env>dev</env> <skipTests>false</skipTests> </properties> <activation> <activeByDefault>true</activeByDefault> </activation> </profile> <!-- 测试环境 --> <profile> <id>test</id> <properties> <spring.profiles.active>test</spring.profiles.active> <env>test</env> <skipTests>true</skipTests> </properties> </profile> <!-- 生产环境 --> <profile> <id>prod</id> <properties> <spring.profiles.active>prod</spring.profiles.active> <env>prod</env> <skipTests>true</skipTests> </properties> </profile> <!-- 性能测试 --> <profile> <id>perf</id> <properties> <spring.profiles.active>perf</spring.profiles.active> <env>perf</env> <skipTests>false</skipTests> </properties> <dependencies> <dependency> <groupId>io.gatling.highcharts</groupId> <artifactId>gatling-charts-highcharts</artifactId> <version>3.9.5</version> <scope>test</scope> </dependency> </dependencies> </profile> <!-- Docker构建 --> <profile> <id>docker</id> <properties> <skipDocker>false</skipDocker> </properties> <build> <plugins> <plugin> <groupId>com.spotify</groupId> <artifactId>dockerfile-maven-plugin</artifactId> <version>1.4.13</version> <executions> <execution> <id>default</id> <goals> <goal>build</goal> </goals> <configuration> <repository>drivingschool/${project.artifactId}</repository> <tag>${project.version}</tag> <buildArgs> <JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE> </buildArgs> </configuration> </execution> </executions> </plugin> </plugins> </build> </profile> <!-- 源码分析 --> <profile> <id>analysis</id> <properties> <skipTests>true</skipTests> </properties> <build> <plugins> <!-- SonarQube分析 --> <plugin> <groupId>org.sonarsource.scanner.maven</groupId> <artifactId>sonar-maven-plugin</artifactId> <version>3.9.1.2184</version> <executions> <execution> <phase>verify</phase> <goals> <goal>sonar</goal> </goals> </execution> </executions> </plugin> <!-- SpotBugs代码检查 --> <plugin> <groupId>com.github.spotbugs</groupId> <artifactId>spotbugs-maven-plugin</artifactId> <version>4.7.3.0</version> <configuration> <effort>Max</effort> <threshold>Low</threshold> <xmlOutput>true</xmlOutput> </configuration> <executions> <execution> <phase>verify</phase> <goals> <goal>check</goal> </goals> </execution> </executions> </plugin> <!-- Checkstyle代码规范检查 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>3.2.0</version> <configuration> <configLocation>checkstyle.xml</configLocation> <encoding>UTF-8</encoding> <consoleOutput>true</consoleOutput> <failsOnError>true</failsOnError> </configuration> <executions> <execution> <phase>verify</phase> <goals> <goal>check</goal> </goals> </execution> </executions> </plugin> <!-- PMD代码质量检查 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-pmd-plugin</artifactId> <version>3.19.0</version> <configuration> <rulesets> <ruleset>rulesets/java/quickstart.xml</ruleset> </rulesets> <printFailingErrors>true</printFailingErrors> </configuration> <executions> <execution> <phase>verify</phase> <goals> <goal>check</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </profile> </profiles> <!-- 项目仓库 --> <repositories> <!-- Maven中央仓库 --> <repository> <id>central</id> <name>Central Repository</name> <url>https://repo.maven.apache.org/maven2</url> <layout>default</layout> <snapshots> <enabled>false</enabled> </snapshots> </repository> <!-- Spring仓库 --> <repository> <id>spring-releases</id> <name>Spring Releases</name> <url>https://repo.spring.io/release</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> <!-- Spring Milestone仓库 --> <repository> <id>spring-milestones</id> <name>Spring Milestones</name> <url>https://repo.spring.io/milestone</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> <!-- Spring Snapshots仓库 --> <repository> <id>spring-snapshots</id> <name>Spring Snapshots</name> <url>https://repo.spring.io/snapshot</url> <releases> <enabled>false</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> <!-- 阿里云仓库(国内加速) --> <repository> <id>aliyun</id> <name>Aliyun Maven</name> <url>https://maven.aliyun.com/repository/public</url> <layout>default</layout> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> <!-- 插件仓库 --> <pluginRepositories> <pluginRepository> <id>central</id> <name>Central Repository</name> <url>https://repo.maven.apache.org/maven2</url> <layout>default</layout> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> <!-- Spring插件仓库 --> <pluginRepository> <id>spring-plugins</id> <name>Spring Plugins</name> <url>https://repo.spring.io/plugins-release</url> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> </pluginRepositories> <!-- 报告 --> <reporting> <plugins> <!-- JaCoCo测试覆盖率报告 --> <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>0.8.8</version> <reportSets> <reportSet> <reports> <report>report</report> </reports> </reportSet> </reportSets> </plugin> <!-- Javadoc报告 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <version>3.4.1</version> <configuration> <encoding>UTF-8</encoding> <docencoding>UTF-8</docencoding> <charset>UTF-8</charset> </configuration> </plugin> <!-- Surefire测试报告 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-report-plugin</artifactId> <version>2.22.2</version> </plugin> <!-- PMD报告 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-pmd-plugin</artifactId> <version>3.19.0</version> <configuration> <rulesets> <ruleset>rulesets/java/quickstart.xml</ruleset> </rulesets> </configuration> </plugin> <!-- Checkstyle报告 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>3.2.0</version> <configuration> <configLocation>checkstyle.xml</configLocation> <encoding>UTF-8</encoding> </configuration> </plugin> <!-- SpotBugs报告 --> <plugin> <groupId>com.github.spotbugs</groupId> <artifactId>spotbugs-maven-plugin</artifactId> <version>4.7.3.0</version> <configuration> <effort>Max</effort> <threshold>Low</threshold> </configuration> </plugin> </plugins> </reporting> </project>
12-15
pom报错: Element encoding is not allowed here:427 Element encoding is not allowed here:427 Plugin' org. apache. maven. plugins: maven-failsafe插in:3.1.2' not found:634 Plugin' org. apache. maven. plugins: maven-failsafe插in:3.1.2' not found:634 Plugin' org. apache. maven. plugins: maven-failsafe插in:3.1.2' not found:635 Plugin' org. apache. maven. plugins: maven-failsafe插in:3.1.2' not found:635 Cannot resolve symbol ' integration-test':639 Cannot resolve symbol ' verify':640 Plugin' org. apache. maven. plugins: maven-surefire报port插in:3.1.2' not found:655 Plugin' org. apache. maven. plugins: maven-surefire报port插in:3.1.2' not found:655 Plugin' org. apache. maven. plugins: maven-surefire报port插in:3.1.2' not found:656 Plugin' org. apache. maven. plugins: maven-surefire报port插in:3.1.2' not found:656 Plugin' org. apache. maven. plugins: maven-project-info-reports插in:3.4.5' not found:662 Plugin' org. apache. maven. plugins: maven-project-info-reports插in:3.4.5' not found:662 Plugin' org. apache. maven. plugins: maven-project-info-reports插in:3.4.5' not found:663 Plugin' org. apache. maven. plugins: maven-project-info-reports插in:3.4.5' not found:663 Plugin' org. owasp: dependency-check-maven:9.0.7' not found:668 Plugin' org. owasp: dependency-check-maven:9.0.7' not found:668 Plugin' org. owasp: dependency-check-maven:9.0.7' not found:669 Plugin' org. owasp: dependency-check-maven:9.0.7' not found:669 Plugin' org. owasp: dependency-check-maven:9.0.7' not found:670 Plugin' org. owasp: dependency-check-maven:9.0.7' not found:670 <?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.drivingschool</groupId> <artifactId>driving-school-system</artifactId> <version>1.0.0</version> <packaging>jar</packaging> <name>driving-school-system</name> <description>驾校学员管理系统 - Spring Boot项目</description> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.7.18</version> <!-- 使用LTS版本 --> <relativePath/> </parent> <properties> <java.version>11</java.version> <maven.compiler.source>11</maven.compiler.source> <maven.compiler.target>11</maven.compiler.target> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <!-- 依赖版本管理 --> <mysql.version>8.0.33</mysql.version> <lombok.version>1.18.30</lombok.version> <mapstruct.version>1.5.5.Final</mapstruct.version> <jjwt.version>0.11.5</jjwt.version> <caffeine.version>3.1.8</caffeine.version> <hibernate.validator.version>6.2.5.Final</hibernate.validator.version> <swagger.version>3.0.0</swagger.version> <flyway.version>9.22.3</flyway.version> <springdoc.version>1.7.0</springdoc.version> </properties> <dependencies> <!-- Spring Boot Starters --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-validation</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-cache</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-aop</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <!-- Thymeleaf Security Integration --> <dependency> <groupId>org.thymeleaf.extras</groupId> <artifactId>thymeleaf-extras-springsecurity5</artifactId> </dependency> <!-- 数据库 --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>${mysql.version}</version> <scope>runtime</scope> </dependency> <dependency> <groupId>com.zaxxer</groupId> <artifactId>HikariCP</artifactId> <scope>compile</scope> </dependency> <!-- 数据库迁移 --> <dependency> <groupId>org.flywaydb</groupId> <artifactId>flyway-core</artifactId> <version>${flyway.version}</version> </dependency> <dependency> <groupId>org.flywaydb</groupId> <artifactId>flyway-mysql</artifactId> <version>${flyway.version}</version> </dependency> <!-- 缓存 --> <dependency> <groupId>com.github.ben-manes.caffeine</groupId> <artifactId>caffeine</artifactId> <version>${caffeine.version}</version> </dependency> <!-- JWT --> <dependency> <groupId>io.jsonwebtoken</groupId> <artifactId>jjwt-api</artifactId> <version>${jjwt.version}</version> </dependency> <dependency> <groupId>io.jsonwebtoken</groupId> <artifactId>jjwt-impl</artifactId> <version>${jjwt.version}</version> <scope>runtime</scope> </dependency> <dependency> <groupId>io.jsonwebtoken</groupId> <artifactId>jjwt-jackson</artifactId> <version>${jjwt.version}</version> <scope>runtime</scope> </dependency> <!-- 工具库 --> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>${lombok.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.mapstruct</groupId> <artifactId>mapstruct</artifactId> <version>${mapstruct.version}</version> </dependency> <dependency> <groupId>org.mapstruct</groupId> <artifactId>mapstruct-processor</artifactId> <version>${mapstruct.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-collections4</artifactId> <version>4.4</version> </dependency> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>32.1.2-jre</version> </dependency> <!-- 验证 --> <dependency> <groupId>org.hibernate.validator</groupId> <artifactId>hibernate-validator</artifactId> <version>${hibernate.validator.version}</version> </dependency> <!-- API文档 --> <dependency> <groupId>org.springdoc</groupId> <artifactId>springdoc-openapi-ui</artifactId> <version>${springdoc.version}</version> </dependency> <dependency> <groupId>org.springdoc</groupId> <artifactId>springdoc-openapi-data-rest</artifactId> <version>${springdoc.version}</version> </dependency> <!-- Excel处理 --> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>5.2.4</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>5.2.4</version> </dependency> <!-- 文件上传处理 --> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>2.13.0</version> </dependency> <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>1.5</version> </dependency> <!-- 二维码生成 --> <dependency> <groupId>com.google.zxing</groupId> <artifactId>core</artifactId> <version>3.5.2</version> </dependency> <dependency> <groupId>com.google.zxing</groupId> <artifactId>javase</artifactId> <version>3.5.2</version> </dependency> <!-- 邮件发送 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-mail</artifactId> </dependency> <!-- 测试依赖 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions> <exclusion> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.testcontainers</groupId> <artifactId>mysql</artifactId> <version>1.19.3</version> <scope>test</scope> </dependency> <dependency> <groupId>org.awaitility</groupId> <artifactId>awaitility</artifactId> <version>4.2.0</version> <scope>test</scope> </dependency> <!-- 开发工具 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> <optional>true</optional> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> <optional>true</optional> </dependency> </dependencies> <dependencyManagement> <dependencies> <!-- 确保所有Spring Boot依赖版本一致 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>2.7.18</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <build> <finalName>driving-school-system</finalName> <plugins> <!-- Spring Boot Maven插件 --> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <excludes> <exclude> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </exclude> </excludes> <layers> <enabled>true</enabled> </layers> <mainClass>com.drivingschool.DrivingSchoolApplication</mainClass> </configuration> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> <!-- 编译插件 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.11.0</version> <configuration> <source>${java.version}</source> <target>${java.version}</target> <annotationProcessorPaths> <path> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>${lombok.version}</version> </path> <path> <groupId>org.mapstruct</groupId> <artifactId>mapstruct-processor</artifactId> <version>${mapstruct.version}</version> </path> <path> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> <version>2.7.18</version> </path> </annotationProcessorPaths> <compilerArgs> <arg>-Amapstruct.defaultComponentModel=spring</arg> <arg>-Amapstruct.unmappedTargetPolicy=IGNORE</arg> </compilerArgs> </configuration> </plugin> <!-- 资源过滤 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>3.3.1</version> <configuration> <delimiters> <delimiter>@</delimiter> </delimiters> <useDefaultDelimiters>false</useDefaultDelimiters> </configuration> </plugin> <!-- 打包时包含依赖的源码 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <version>3.3.0</version> <executions> <execution> <id>attach-sources</id> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin> <!-- 打包时包含JavaDoc --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <version>3.6.3</version> <executions> <execution> <id>attach-javadocs</id> <goals> <goal>jar</goal> </goals> <configuration> <doclint>none</doclint> </configuration> </execution> </executions> </plugin> <!-- 代码质量检查 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>3.3.0</version> <configuration> <configLocation>checkstyle.xml</configLocation> <encoding>UTF-8</encoding> <consoleOutput>true</consoleOutput> <failsOnError>true</failsOnError> <linkXRef>false</linkXRef> </configuration> <executions> <execution> <id>validate</id> <phase>validate</phase> <goals> <goal>check</goal> </goals> </execution> </executions> </plugin> <!-- 测试覆盖率 --> <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>0.8.10</version> <executions> <execution> <goals> <goal>prepare-agent</goal> </goals> </execution> <execution> <id>report</id> <phase>test</phase> <goals> <goal>report</goal> </goals> </execution> <execution> <id>check</id> <goals> <goal>check</goal> </goals> <configuration> <rules> <rule> <element>BUNDLE</element> <limits> <limit> <counter>INSTRUCTION</counter> <value>COVEREDRATIO</value> <minimum>0.80</minimum> </limit> </limits> </rule> </rules> </configuration> </execution> </executions> </plugin> <!-- Docker构建插件 --> <plugin> <groupId>com.google.cloud.tools</groupId> <artifactId>jib-maven-plugin</artifactId> <version>3.4.0</version> <configuration> <from> <image>eclipse-temurin:11-jre-focal</image> <platforms> <platform> <architecture>amd64</architecture> <os>linux</os> </platform> <platform> <architecture>arm64</architecture> <os>linux</os> </platform> </platforms> </from> <to> <image>driving-school-system:${project.version}</image> </to> <container> <entrypoint> <entry>java</entry> <entry>-cp</entry> <entry>/app/resources:/app/classes:/app/libs/*</entry> <entry>com.drivingschool.DrivingSchoolApplication</entry> </entrypoint> <ports> <port>8080</port> </ports> <environment> <TZ>Asia/Shanghai</TZ> </environment> <creationTime>USE_CURRENT_TIMESTAMP</creationTime> </container> </configuration> </plugin> </plugins> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> <includes> <include>**/*.properties</include> <include>**/*.yml</include> <include>**/*.yaml</include> <include>**/*.xml</include> </includes> </resource> <resource> <directory>src/main/resources</directory> <filtering>false</filtering> <excludes> <exclude>**/*.properties</exclude> <exclude>**/*.yml</exclude> <exclude>**/*.yaml</exclude> <exclude>**/*.xml</exclude> </excludes> </resource> </resources> </build> <profiles> <!-- 开发环境配置 --> <profile> <id>dev</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <spring.profiles.active>dev</spring.profiles.active> <maven.test.skip>true</maven.test.skip> </properties> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <profiles> <profile>dev</profile> </profiles> <jvmArguments>-Xmx512m -Xms256m</jvmArguments> </configuration> </plugin> </plugins> </build> </profile> <!-- 测试环境配置 --> <profile> <id>test</id> <properties> <spring.profiles.active>test</spring.profiles.active> </properties> </profile> <!-- 生产环境配置 --> <profile> <id>prod</id> <properties> <spring.profiles.active>prod</spring.profiles.active> <maven.test.skip>true</maven.test.skip> </properties> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <profiles> <profile>prod</profile> </profiles> <jvmArguments> -Xmx1024m -Xms512m -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp/heapdump.hprof </jvmArguments> </configuration> </plugin> </plugins> </build> </profile> <!-- 打包跳过测试 --> <profile> <id>package-only</id> <properties> <maven.test.skip>true</maven.test.skip> <skipTests>true</skipTests> </properties> </profile> <!-- 运行集成测试 --> <profile> <id>integration-test</id> <properties> <maven.test.skip>false</maven.test.skip> <skipTests>false</skipTests> <skipITs>false</skipITs> </properties> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> <version>3.1.2</version> <executions> <execution> <goals> <goal>integration-test</goal> <goal>verify</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </profile> </profiles> <reporting> <plugins> <!-- 测试报告 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-report-plugin</artifactId> <version>3.1.2</version> </plugin> <!-- 依赖分析 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-project-info-reports-plugin</artifactId> <version>3.4.5</version> </plugin> <!-- 依赖检查 --> <plugin> <groupId>org.owasp</groupId> <artifactId>dependency-check-maven</artifactId> <version>9.0.7</version> <reportSets> <reportSet> <reports> <report>aggregate</report> </reports> </reportSet> </reportSets> </plugin> </plugins> </reporting> <!-- 仓库配置 --> <repositories> <repository> <id>aliyun</id> <name>Aliyun Maven</name> <url>https://maven.aliyun.com/repository/public</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> <repository> <id>central</id> <name>Central Repository</name> <url>https://repo.maven.apache.org/maven2</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>aliyun</id> <name>Aliyun Plugin Repository</name> <url>https://maven.aliyun.com/repository/public</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> </pluginRepositories> </project>
最新发布
12-17
jar打包方式<?xml version="1.0" encoding="UTF-8"?> <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <parent> <groupId>com.carbonfootprint</groupId> <artifactId>carbonfootprint-common</artifactId> <version>3.6.5</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>carbonfootprint-common-chainmaker</artifactId> <description> carbonfootprint-common-maker存证合约 </description> <dependencies> <!-- java-sdk中的依赖 --> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-pool2</artifactId> <version>2.11.1</version> </dependency> <dependency> <groupId>org.web3j</groupId> <artifactId>abi</artifactId> <version>5.0.0</version> </dependency> <dependency> <groupId>org.chainmaker</groupId> <artifactId>chainmaker-sdk-java</artifactId> <version>2.3.1.3</version> </dependency> <dependency> <groupId>io.netty</groupId> <artifactId>netty-tcnative-openssl-static</artifactId> <scope>system</scope> <version>2.0.39.Final</version> <systemPath>${project.basedir}/lib/netty-tcnative-openssl-static-2.0.39.Final.jar</systemPath> </dependency> <dependency> <groupId>io.netty</groupId> <artifactId>netty-handler</artifactId> <version>4.1.53.Final</version> </dependency> <dependency> <groupId>io.grpc</groupId> <artifactId>grpc-api</artifactId> <version>1.23.0</version> </dependency> <dependency> <groupId>io.grpc</groupId> <artifactId>grpc-netty</artifactId> <version>1.23.0</version> </dependency> <dependency> <groupId>io.grpc</groupId> <artifactId>grpc-stub</artifactId> <version>1.23.0</version> </dependency> <dependency> <groupId>io.grpc</groupId> <artifactId>grpc-protobuf</artifactId> <version>1.23.0</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>3.3.0</version> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project>
12-12
<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.grade</groupId> <artifactId>grade-management</artifactId> <version>1.0-SNAPSHOT</version> <packaging>war</packaging> <!-- 打包为WAR包(Web应用) --> <<dependencies> <!-- 1. Servlet API 依赖(Tomcat已提供,编译时依赖即可) --> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>4.0.1</version> <scope>provided</scope> </dependency> <!-- 2. MySQL 驱动依赖(连接数据库用) --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.33</version> </dependency> <!-- 3. JSTL 依赖(若后续用JSTL标签库遍历列表等,可选) --> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> </</dependencies> <build> <finalName>grade-management</finalName> <!-- 最终WAR包名称,需与Tomcat部署名称一致 --> <plugins> <!-- 编译插件:指定Java版本(与本地JDK和Tomcat兼容,这里选Java 8) --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <source>8</source> <target>8</target> </configuration> </plugin> <!-- WAR打包插件:用于生成可部署的WAR包 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>3.3.2</version> </plugin> </plugins> </build> </project>
10-24
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值