簡體   English   中英

無法部署Spring Boot Jar應用程序

[英]Unable to deploy spring boot jar application

我正在開發一個Spring Boot應用程序,當我運行命令時它可以正常工作:

mvn spring-boot:run

但是,使用以下命令部署jar文件時:

java -jar target\\jarfile.jar

我收到以下錯誤:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'employeeResource': Unsatisfied dependency expressed through field 'hrServicesSilo'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'hrServicesSilo': Unsatisfied dependency expressed through field 'employeeService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'employeeService': Unsatisfied dependency expressed through field 'employeeRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'employeeRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class com.intranet.si.model.hr.Employee
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
        at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]

我究竟做錯了什么?

我可以看到一個repository所以我假設您使用spring-data 奇怪的是,它可以在Maven中工作,並且在打包后不工作,因此您可以嘗試以下操作:

  1. 檢查您是否使用spring-maven-plugin打包您的應用程序。
  2. 嘗試將@EntityScan("com.intranet.si.model.hr") (也可以是com.intranet.si.model來遞歸地捕獲包和子包中的所有模型)添加到配置類之一或應用程序類(用@SpringBootApplication注釋的@SpringBootApplication )。 這將通知spring + hibernate在哪里掃描實體。 還要確保您的實體使用@Entity注釋。
  3. 我猜您其中一個配置文件中已經有@EnableJpaRespotories ,但請確保也對其進行了配置。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM