基本上我有一个Maven项目,我正在尝试通过pom.xml下面的spring工具套件使用mvn clean compile package
生成我的项目的jar。
执行命令后,我在target
文件夹中生成了2个jar文件-{project-name} .jar和{project-name} .jar.original
.jar
文件包含
Spring boot framework class files拥有contents,而.jar.original
文件包含我的应用程序的实际类文件。
我也尝试使用mvn clean install
,但运气不佳。此外,仅安装了一个对我无用的文件,因为它不包含我的应用程序的任何class
文件,但包含spring框架类。
pom.xml
<?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.commonporject</groupId>
<artifactId>commonporject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>commonporject</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.ibm.db2.jcc</groupId>
<artifactId>db2jcc4</artifactId>
<version>10.1</version>
</dependency>
<!-- other dependencies -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerVersion>1.8</compilerVersion>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Console
:
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< com.commonporject:commonporject >----------------------
[INFO] Building commonporject 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ commonporject ---
[INFO] Deleting C:\Users\Aadil\Documents\workspace-spring-tool-suite-4-4.0.0.RELEASE\commonporject\target
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ commonporject ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ commonporject ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 6 source files to C:\Users\Aadil\Documents\workspace-spring-tool-suite-4-4.0.0.RELEASE\commonporject\target\classes
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ commonporject ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ commonporject ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ commonporject ---
[INFO] Not copying test resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ commonporject ---
[INFO] Not compiling test sources
[INFO]
[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ commonporject ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:3.1.0:jar (default-jar) @ commonporject ---
[INFO] Building jar: C:\Users\Aadil\Documents\workspace-spring-tool-suite-4-4.0.0.RELEASE\commonporject\target\commonporject-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.1.0.RELEASE:repackage (repackage) @ commonporject ---
[INFO] Replacing main artifact C:\Users\Aadil\Documents\workspace-spring-tool-suite-4-4.0.0.RELEASE\commonporject\target\commonporject-0.0.1-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.706 s
[INFO] Finished at: 2018-11-04T12:28:37+05:30
[INFO] ------------------------------------------------------------------------
答案 0 :(得分:1)
spring-boot-maven插件默认使用重新打包目标,该目标打包了pom文件中提到的所有依赖项。发生这种情况时,您项目的类和资源jar将重命名为“原始”。
请参阅以下文档以获取有关此插件的更多详细信息。
https://docs.spring.io/spring-boot/docs/current/reference/html/build-tool-plugins-maven-plugin.html