升级Maven至3.9.9后构建Jar失败:无法加载主类mic.App
问题:Maven 3.9.9构建可执行Jar包后无法找到主类mic.App
我使用Maven 3.9.9配合下述依赖构建合并Jar包,此前用Maven 3.8.8版本构建的Jar包能正常运行,但升级到3.9.9后,新生成的Jar包运行时报错:Could not find or load main class mic.App。当前开发环境为Java 8。
相关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>AB</groupId> <artifactId>TESTJAVA</artifactId> <version>41.1</version> <name>TESTJAVA</name> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> </properties> <dependencies> <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-simple</artifactId> <version>1.7.26</version> </dependency> <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.26</version> </dependency> <!-- https://mvnrepository.com/artifact/com.google.protobuf/protobuf-java --> <dependency> <groupId>com.google.protobuf</groupId> <artifactId>protobuf-java</artifactId> <version>3.21.7</version> </dependency> <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core --> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>2.13.0</version> </dependency> <!-- Local Dependecies --> <dependency> <groupId>msdrg</groupId> <artifactId>msdrg</artifactId> <version>41.1.0.0</version> <scope>system</scope> <systemPath>${pom.basedir}/lib/abc-v411-41.1.0.0.jar</systemPath> </dependency> <dependency> <groupId>binary-access</groupId> <artifactId>binary-access</artifactId> <version>1.1.0</version> <scope>system</scope> <systemPath>${pom.basedir}/lib/bsdry-abcs-1.1.0.jar</systemPath> </dependency> <dependency> <groupId>gfc-base-api</groupId> <artifactId>gfc-base-api</artifactId> <version>3.4.9</version> <scope>system</scope> <systemPath>${pom.basedir}/lib/ga-bsde-aai-3.4.9.jar</systemPath> </dependency> <dependency> <groupId>msdrg-model</groupId> <artifactId>msdrg-model</artifactId> <version>2.5.0</version> <scope>system</scope> <systemPath>${pom.basedir}/lib/mssd-modasl-v2-2.5.0.jar</systemPath> </dependency> <!-- Testing Dependencies --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <archive> <manifest> <mainClass>mic/App</mainClass> <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries> <addDefaultImplementationEntries>true</addDefaultImplementationEntries> </manifest> <manifestEntries> <Java-Version>${java.version}</Java-Version> <Java-Vendor>${java.vendor}</Java-Vendor> <Os-Name>${os.name}</Os-Name> <Os-Arch>${os.arch}</Os-Arch> <Os-Version>${os.version}</Os-Version> </manifestEntries> </archive> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> <finalName>${project.artifactId}-${project.version}</finalName> <appendAssemblyId>false</appendAssemblyId> </configuration> <executions> <execution> <id>make-assembly</id> <!-- this is used for inheritance merges --> <phase>package</phase> <!-- bind to the packaging phase --> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project>
我尝试过升级slf4j-simple、slf4j-api、protobuf-java和jackson-core依赖,但问题仍未解决。
内容的提问来源于stack exchange,提问作者Abhishek Maurya
相关产品推荐
相关产品推荐

