【发布时间】:2018-12-19 06:58:25
【问题描述】:
在将我的应用程序作为 Java 应用程序运行时,项目构建路径中包含的 jar 被发现并运行而没有任何错误。当我尝试通过执行java -jar myApp.jar 来运行应用程序时,找不到来自外部 jar 的使用的类。
线程“main”中的异常 org.springframework.beans.factory.CannotLoadBeanClassException:找不到类路径资源 [appContext.xml] 中定义的名称为“blackboard”的 bean 的类 [com.escomled.blackboard.impl.BlackboardImpl] ;
【问题讨论】:
-
使用 Maven Shade 插件。
-
这样的?
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>2.4.3</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <artifactSet> <includes> <include>escomled:escomled-common:jar:0.0.1</include> </includes> </artifactSet> </configuration> </execution> </executions> </plugin> -
请使用更新版本的maven-shade-plugin