首页 新闻 会员 周边 捐助

java 打包后引用jar包方法找不到

0
悬赏园豆:50 [已解决问题] 解决于 2021-02-02 15:08

IDEA 上运行是ok的,打jar包部署到服务器或者本机,就报错,应用的tibco jar包貌似没
打包进来,百度各种方式都试了。
可留联系方式,解决了发红包。

启动 代码
@SpringBootApplication
@ServletComponentScan(basePackages = "com.fdcweb.filter")
@EnableAutoConfiguration
@EnableScheduling
@EnableAsync
public class FdcwebApplication {

public static void main(String[] args) {
	SpringApplication.run(FdcwebApplication.class, args);
	String service = "1200";
	String network = ";225.19.19.12";
	String daemon = "7500";
	String subject = "cm.test";
	RvlistenerDemo rl = new RvlistenerDemo(service, network, daemon, subject);
}

}

报错信息
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:107)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)
Caused by: java.lang.NoClassDefFoundError: com/tibco/tibrv/TibrvMsgCallback
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:151)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.fdcweb.FdcwebApplication.main(FdcwebApplication.java:24)
... 8 more
Caused by: java.lang.ClassNotFoundException: com.tibco.tibrv.TibrvMsgCallback
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:151)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 21 more

nieaitan520的主页 nieaitan520 | 初学一级 | 园豆:47
提问于:2021-01-28 16:12
< >
分享
最佳答案
0

pom.xml的打jar包换成这种:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>codes.showme.mavenrepocrawler.Crawler</mainClass> <!-- 此处为主入口-->
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<!--<configuration>-->
<!--<outputDirectory>${project.build.directory}/lib-->
<!--</outputDirectory>-->
<!--</configuration>-->
</execution>
</executions>
</plugin>

然后Teminal 输入mvn clean install

然后会在targer目录生成一个dependency的目录。在里面查看所有依赖的jar到底有否打进去
前几天也碰到了依赖打不进去的问题。这样能快速排查出来

收获园豆:50
Ctrl` | 老鸟四级 |园豆:3317 | 2021-01-28 16:30

<goals>
<goal>copy-dependencies</goal>
</goals>
这个 地方 爆红

nieaitan520 | 园豆:47 (初学一级) | 2021-01-28 17:10

没有打进来

nieaitan520 | 园豆:47 (初学一级) | 2021-01-28 17:11

nieaitan520 | 园豆:47 (初学一级) | 2021-01-28 17:16

@nieaitan520: 爆红那个不影响。你tibco这个包怎么引入的。maven坐标还是外部依赖

Ctrl` | 园豆:3317 (老鸟四级) | 2021-01-29 09:13

@Ctrl`: 打包成功了,分享下方法,留下电话,给你充点话费,幸苦大哥了。
<dependency>
<groupId>com.tibco</groupId>
<artifactId>tibrvj</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/tibrvj.jar</systemPath>
</dependency>
引入外部依赖的包,指定路径
打包的时候
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<includeSystemScope>true</includeSystemScope> <!-- 打包 将外部jar,打包进项目中 -->
</configuration>
</plugin>

nieaitan520 | 园豆:47 (初学一级) | 2021-01-29 11:05

昨天打包不成功是看到网上说<artifactId>tibrvj</artifactId> 这个地方随便写,我就写了<artifactId>com.tibrvj</artifactId>,结果是指定的文件夹,今天我看了写log,找到原因了,谢谢大哥,大哥辛苦了

nieaitan520 | 园豆:47 (初学一级) | 2021-01-29 11:09

@nieaitan520: 。没事的 解决了就好,话费就免了。正常结下贴就行 -

Ctrl` | 园豆:3317 (老鸟四级) | 2021-01-29 13:11
其他回答(1)
0

tibco jar 是引了多个版本的吗

平淡日子里的刺- | 园豆:206 (菜鸟二级) | 2021-01-28 16:21
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册