Spring Boot 2 + Apache Shiro CGLIB代理

时间:2019-01-01 12:55:54

标签: spring-boot shiro

有人让Apache Shiro与Spring Boot 2一起工作吗?

Shiro依赖于Spring的旧版本,并导致我的某些bean被代理,从而导致如下错误。

  

2019-01-01 16:15:20,713调试[restartedMain] org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter:应用程序由于异常而无法启动                   org.springframework.beans.factory.BeanNotOfRequiredTypeException:名为“ prescriptionService”的Bean的类型应为“ com.nusrcraft.flexinics.feature.clinic.prescription.PrescriptionService”,但实际上是“ com.sun.proxy。$ Proxy92”类型'

可以通过以下方法解决此错误:为被代理的bean创建接口-但不会在生产中应用此解决方案。

  

使用org.apache.shiro:shiro-spring-boot-starter:1.4.0

     

2019-01-01 16:15:20,713调试[restartedMain] org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter:应用程序由于异常而无法启动                   org.springframework.beans.factory.BeanNotOfRequiredTypeException:名为“ prescriptionService”的Bean的类型应为“ com.nusrcraft.flexinics.feature.clinic.prescription.PrescriptionService”,但实际上是“ com.sun.proxy。$ Proxy92”类型'

完整跟踪:

 2019-01-01 16:15:20,711 DEBUG [restartedMain] org.springframework.boot.diagnostics.FailureAnalyzers: FailureAnalyzer org.springframework.boot.autoconfigure.jdbc.HikariDriverConfigurationFailureAnalyzer@f0a4f33 failed
 java.lang.TypeNotPresentException: Type org.springframework.jdbc.CannotGetJdbcConnectionException not present
     at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:117)
     at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:125)
     at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
     at sun.reflect.generics.visitor.Reifier.reifyTypeArguments(Reifier.java:68)
     at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:138)
     at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
     at sun.reflect.generics.repository.ClassRepository.getSuperclass(ClassRepository.java:90)
     at java.lang.Class.getGenericSuperclass(Class.java:777)
     at org.springframework.core.ResolvableType.getSuperType(ResolvableType.java:466)
     at org.springframework.core.ResolvableType.as(ResolvableType.java:455)
     at org.springframework.core.ResolvableType.forClass(ResolvableType.java:1037)
     at org.springframework.boot.diagnostics.AbstractFailureAnalyzer.getCauseType(AbstractFailureAnalyzer.java:58)
     at org.springframework.boot.diagnostics.AbstractFailureAnalyzer.analyze(AbstractFailureAnalyzer.java:34)
     at org.springframework.boot.diagnostics.FailureAnalyzers.analyze(FailureAnalyzers.java:114)
     at org.springframework.boot.diagnostics.FailureAnalyzers.reportException(FailureAnalyzers.java:107)
     at org.springframework.boot.SpringApplication.reportFailure(SpringApplication.java:848)
     at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:832)
     at org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
     at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
     at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
     at com.nusrcraft.flexinics.FlexinicsWebApplication.main(FlexinicsWebApplication.java:37)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
     at java.lang.reflect.Method.invoke(Method.java:498)
     at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
 Caused by: java.lang.ClassNotFoundException: org.springframework.jdbc.CannotGetJdbcConnectionException
     at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
     at java.lang.Class.forName0(Native Method)
     at java.lang.Class.forName(Class.java:348)
     at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:114)
     ... 25 common frames omitted
 2019-01-01 16:15:20,713 DEBUG [restartedMain] org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter: Application failed to start due to an exception
 org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'prescriptionService' is expected to be of type 'com.nusrcraft.flexinics.feature.clinic.prescription.PrescriptionService' but was actually of type 'com.sun.proxy.$Proxy92'
     at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1247)
     at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1164)
     at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:593)
     at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90)
     at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:374)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1378)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:575)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498)
     at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
     at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:846)
     at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:863)
     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
     at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142)
     at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
     at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
     at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
     at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
     at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
     at com.nusrcraft.flexinics.FlexinicsWebApplication.main(FlexinicsWebApplication.java:37)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
     at java.lang.reflect.Method.invoke(Method.java:498)
     at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)

0 个答案:

没有答案