简体   繁体   English

具有jar依赖项的Spring Boot应用程序在Maven构建后无法运行

[英]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. 我正在编写一个Spring Boot应用程序,它需要从ibm notes数据库中获取记录。 For that I have to use a jar library which is not available as a maven dependency. 为此,我必须使用无法作为Maven依赖项使用的jar库。 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. 因此,我将jar放在lib / com / ibm / notes / 1.0.0 / notes-1.0.0.jar的项目主页中,并将其作为本地存储库添加到pom文件中,如下所示。

<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. 在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. 但是当我通过右键单击eclipse上的pom文件来清理/安装相同的项目时,构建成功并带有以下警告。

[INFO] --------------------------------[ jar ]--------------------------------- [WARNING] The POM for com.ibm:notes:jar:1.0.0 is missing, no dependency information available [INFO] -------------------------------- [jar] ------------ --------------------- [警告] com.ibm:notes:jar:1.0.0的POM丢失,没有可用的依赖项信息

But application execution fails at command line. 但是应用程序执行在命令行失败。 Below is the error I get. 以下是我得到的错误。

Error starting ApplicationContext. 启动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 2019-08-17 16:37:41.450错误17868 --- [main] osboot.SpringApplication
: Application run failed :应用程序运行失败

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'craNotesService': Unsatisfied dependency expressed through field 'repository'; org.springframework.beans.factory.UnsatisfiedDependencyException:创建名称为“ craNotesService”的bean时出错:通过字段“存储库”表示的不满足的依赖关系; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'craNotesRepository': Lookup method resolution failed; 嵌套的异常是org.springframework.beans.factory.BeanCreationException:创建名称为'craNotesRepository'的bean时出错:查找方法解析失败; 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] 嵌套异常是java.lang.IllegalStateException:无法从org.springframework.boot.loader.LaunchedURLClassLoader@5c7fa833的ClassLoader [org.springframework.boot.loader.LaunchedURLClassLoader@5c7fa833]内省了类[q2c.project7.craservice.repository.CraNotesRepository]。 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. CraNotesRepository是利用上面指定的外部jar的类。

try to install notes-1.0.0.jar manually from cmd like this 尝试像这样从cmd手动安装notes-1.0.0.jar

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. 我正在eclipse项目中使用32位jdk进行开发,而我的机器具有64位jdk。 Notes jar only supports 32 bit. Notes jar仅支持32位。 So running it in 64 bit jdk fails to load the classes from Notes jar file. 因此,在64位jdk中运行它无法从Notes jar文件中加载类。 Changing machine jdk also to 32 bit solved the issue. 将机器jdk也更改为32位即可解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 maven 依赖项中添加 pubnub 后,Spring Boot 应用程序不启动 - Spring boot application does not start after adding pubnub in maven dependency 如何使用 maven 的 spring 引导应用程序的构建库 jar - How a build library jar of spring boot application using maven 无法运行Spring Boot Maven应用程序的jar文件 - Unable to Run jar File of Spring Boot Maven Application 添加 Jpa maven 依赖后无法运行 spring boot app - Cannot run spring boot app after adding Jpa maven dependency Teamcity-在构建和部署后如何在服务器上运行spring boot jar? - Teamcity - How to run spring boot jar on server after Build and Deploy? 如何使用外部 jars 运行 spring-boot jar 并使用 maven 依赖系统编译? - How to run a spring-boot jar with external jars which compile with maven dependency system? 构建 jar 并运行 spring 从 cmd 启动 - Build jar and run spring boot from cmd 使用java.jar以tools.jar作为依赖项运行spring boot - run spring boot with java -jar with tools.jar as dependency Spring Boot Maven plugin - How do I build a zip file with Java jar file and script to run it? - Spring Boot Maven plugin - How do I build a zip file with Java jar file and script to run it? Spring 启动 maven 插件 - 如何构建可执行 jar 并包含运行它的脚本? - Spring Boot maven plugin - how do I build an executable jar and include a script to run it?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM