linux - 在 Linux 服务器上通过 xldeploy 和 jenkins 部署 thin jar 时出错

标签 linux spring spring-boot jar spring-batch

我有一个 spring boot/batch 应用程序,它在使用 jenkins 和 xldeploy 部署时抛出错误。它是一个渐变应用程序。

当我将它作为一个 fat jar 直接部署在服务器上时它工作正常,但是当我通过 jenkins 和 xldeploy 部署该 jar 时它给我以下错误。

Error creating bean with name 'jobOperator' defined in class path resource [com/one/RetirementConversionImport/standalone/BatchConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class com.one.RetirementConversionImport.standalone.BatchConfiguration$1]: Common causes of this problem include using a final class or a non-visible class; nested exception is org.springframework.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:562) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:754) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866) ~[spring-context-4.3.4.RELEASE.jar:4.3.4.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) ~[spring-context-4.3.4.RELEASE.jar:4.3.4.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) [spring-boot-1.4.2.RELEASE.jar:1.4.2.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371) [spring-boot-1.4.2.RELEASE.jar:1.4.2.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-1.4.2.RELEASE.jar:1.4.2.RELEASE] at com.paychex.RetirementConversionImport.standalone.RetirementConversionImport.main(RetirementConversionImport.java:85) [RetirementConversionImport.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_131] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_131] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_131] at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-1.4.2.RELEASE.jar:1.4.2.RELEASE] Caused by: org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class com.paychex.RetirementConversionImport.standalone.BatchConfiguration$1]: Common causes of this problem include using a final class or a non-visible class; nested exception is org.springframework.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null

最佳答案

根本原因是类路径中有 spring-boot-devtools。删除 devtools 解决了问题。所以在这种情况下,问题基本上出在 AOP 代理上。出于某种原因,我们必须关闭 AOP 代理,这将确保它使用 JDK 代理,这可以通过删除 spring-boot-devtools jar 来完成,删除它会启动它以使用 native JDK 代理并修复此错误。

关于linux - 在 Linux 服务器上通过 xldeploy 和 jenkins 部署 thin jar 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47288793/

相关文章:

linux - 打印前 Lisp 奇怪的新行

java - 在 AuthenticationSuccessHandler 中设置 session 范围的对象

java - 如何在spring boot中重新加载外部属性文件而不需要重启tomcat?

java - RSocket 适用于生成的数据,但不适用于 Spring Reactive MongoDB

java - 如何解决 Spring Boot 上的 org.testcontainers.containers.ContainerFetchException?

linux - Bash 中意外标记 'elif' 附近的语法错误

linux - 创建颠覆分支

linux - 检测shell脚本的输出流类型

java - Spring 无法在多个 TransactionManager bean 之间进行选择

java - @CacheEvict 的动态参数