简体   繁体   中英

Spring Boot application with a jar dependency does not run after maven build

I am writing a spring boot application and it needs to fetch records from a ibm notes database. For that I have to use a jar library which is not available as a maven dependency. So I placed the jar in project home as lib/com/ibm/notes/1.0.0/notes-1.0.0.jar and have added it as a local repository in the pom file as below.

<repositories>
    <repository>
        <id>ProjectRepo</id>
        <url>file://${project.basedir}/lib</url>
    </repository>
</repositories>

<dependency>
    <groupId>com.ibm</groupId>
    <artifactId>notes</artifactId>
    <version>1.0.0</version>
</dependency>

My application runs without any problem when executed inside eclipse IDE. But when I maven clean/install the same project by right clicking on pom file from eclipse, the build is success with below warning.

[INFO] --------------------------------[ jar ]--------------------------------- [WARNING] The POM for com.ibm:notes:jar:1.0.0 is missing, no dependency information available

But application execution fails at command line. Below is the error I get.

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2019-08-17 16:37:41.450 ERROR 17868 --- [ main] osboot.SpringApplication
: Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'craNotesService': Unsatisfied dependency expressed through field 'repository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'craNotesRepository': Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [q2c.project7.craservice.repository.CraNotesRepository] from ClassLoader [org.springframework.boot.loader.LaunchedURLClassLoader@5c7fa833] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:596) ~[spring-beans-5.1.9.RELEASE.jar!/:5.1.9.RELEASE]

Could you please advise how to fix the issue?

CraNotesRepository is the class which utilize the external jar specified above.

try to install notes-1.0.0.jar manually from cmd like this

mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> \
    -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>

I was developing using a 32 bit jdk in eclipse project and my machine has 64 bit jdk. Notes jar only supports 32 bit. So running it in 64 bit jdk fails to load the classes from Notes jar file. Changing machine jdk also to 32 bit solved the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM