问题
I want to add 3rd party external jar into my maven repository. My project is in Spring Boot.
Error :
`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:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:51)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52)
Caused by: java.lang.NoClassDefFoundError: com/omnesys/omne/om/OMNM
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at com.omnesys.nestq.classes.ClassNestQ12.<init>(ClassNestQ12.java:28)
at com.omnesys.nestq.classes.NestControl.<init>(NestControl.java:39)
at orion.ibclient.OmnesysJAPI.<init>(OmnesysJAPI.java:69)
at orion.TradingProgram.connectToNest(TradingProgram.java:452)
at orion.TradingProgram.main(TradingProgram.java:90)
at com.orion.main.OrionController.loadPrperty(OrionController.java:39)
at com.orion.main.NestOrionApplication.main(NestOrionApplication.java:21
)
... 8 more
Caused by: java.lang.ClassNotFoundException: com.omnesys.omne.om.OMNM
at java.lang.ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 19 more`
I had done following things but still I am getting the same error.
NOTE : It working for other jar but not worked only for this jar. Like for DealerSample.jar its working but not working for this jar. You can see the difference in below picture. When I added the same jar in Simple java project through Build path its working but not in Spring Boot project.
- Add external jar : https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html : Added my jar to .m2 folder and add dependancy into maven.
Maven Command : mvn install:install-file -Dfile=D:\Vijay\Jars\OmneVerse.15.0.0.0.jar -DgroupId=com.orion -DartifactId=OmneVerse -Dversion=1.0.0 -Dpackaging=jar -DgeneratePom=true
Pom.xml:
<dependencies>
<dependency>
<groupId>com.orion</groupId>
<artifactId>OmneVerse</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<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>
</configuration>
</plugin>
</plugins>
</build>
My Project Libs structure :
回答1:
Why not try Nexus Repository Manager? Though this approach may be long and complex. But I think it is the best and lasting solution to your problem. I have used it many times and find it very helpful.
来源:https://stackoverflow.com/questions/62449991/maven-caused-by-java-lang-noclassdeffounderror-com-omnesys-omne-om-omn