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

2021-02-02 14:25发布

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

标签: java
2条回答
【Aperson】
2楼-- · 2021-02-02 14:58

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到底有否打进去
前几天也碰到了依赖打不进去的问题。这样能快速排查出来

查看更多
smile是对你的礼貌
3楼-- · 2021-02-02 14:59

tibco jar 是引了多个版本的吗

查看更多
登录 后发表回答