无法找到SpelEvaluationException方法 [英] SpelEvaluationException Method cannot be found
问题描述
我正面临下一个问题,当我尝试使用SpEL将用户传递给服务方法时,
I am facing with the next problem, when I am trying to pass the User to the service method using SpEL,
evaluate expression="commonService.userTest(user)" result="flowScope.user"
spring throwows me以下异常:
spring throws me the following exception:
org.springframework.expression.spel.SpelEvaluationException:EL1004E:(pos 14):方法调用:方法userTest(com在com.sun.proxy上找不到.x.domain.common.User。$ Proxy114类型
org.springframework.expression.spel.SpelEvaluationException: EL1004E:(pos 14): Method call: Method userTest(com.x.domain.common.User) cannot be found on com.sun.proxy.$Proxy114 type
但是当我路过时纯文本而不是User对象,
But when I am passing a plain text instead of the User object,
evaluate expression="commonService.userTest('Hello')" result="flowScope.user"
没有错误。
@Entity
@Table(name = "users")
@Getter
@Setter
@NoArgsConstructor
@Slf4j
public class User extends BaseEntity implements UserDetails {
@Column(unique = true)
@NotEmpty
private String username;
@Column
@NotEmpty
@Size(min = 5)
private String password;
}
@Service("commonService")
public class CommonServiceImpl implements CommonService {
@Transactional(readOnly = true)
@Override
public User userTest(String name) {
User user = createUser();
user.setUsername(name);
return user;
}
@Transactional(readOnly = true)
@Override
public User userTest(User user) {
return user;
}
}
推荐答案
更新#2 - 解决方法
删除DevTools依赖项解决了问题,但应用此解决方案 Spring Boot Dev Tools& Web Flow不能很好用,但在 src / main / resources / META-INF / 下创建
spring-devtools.properties
code>使用以下行使其完全没问题
Removing DevTools dependency solved the problem, but applying this solution Spring Boot Dev Tools & Web Flow don't play nice but creating spring-devtools.properties
under src/main/resources/META-INF/
with the following line makes it works with no problem at all
restart.include.spring=/.*\.jar
为什么我没有链接中提到的这一行:
Why I didn't this line as mentioned in the link:
restart.include.spring=/spring-.*\.jar
因为我得到了这个例外
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webFlowConfig': Unsatisfied dependency expressed through field 'webMvcConfig'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webMvcConfig': Unsatisfied dependency expressed through field 'springTemplateEngine'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$ThymeleafDefaultConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultTemplateResolver' defined in class path resource [org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration$Thymeleaf3Configuration$DefaultTemplateResolverConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver]: Factory method 'defaultTemplateResolver' threw exception; nested exception is java.lang.LinkageError: loader constraint violation: when resolving method "org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver.setApplicationContext(Lorg/springframework/context/ApplicationContext;)V" the class loader (instance of org/springframework/boot/devtools/restart/classloader/RestartClassLoader) of the current class, org/springframework/boot/autoconfigure/thymeleaf/AbstractTemplateResolverConfiguration, and the class loader (instance of sun/misc/Launcher$AppClassLoader) for the method's defining class, org/thymeleaf/spring4/templateresolver/SpringResourceTemplateResolver, have different Class objects for the type org/springframework/context/ApplicationContext used in the signature
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) ~[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at medicallab.MedicallabApplication.main(MedicallabApplication.java:10) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-1.5.6.RELEASE.jar:1.5.6.RELEASE]
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webMvcConfig': Unsatisfied dependency expressed through field 'springTemplateEngine'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$ThymeleafDefaultConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultTemplateResolver' defined in class path resource [org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration$Thymeleaf3Configuration$DefaultTemplateResolverConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver]: Factory method 'defaultTemplateResolver' threw exception; nested exception is java.lang.LinkageError: loader constraint violation: when resolving method "org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver.setApplicationContext(Lorg/springframework/context/ApplicationContext;)V" the class loader (instance of org/springframework/boot/devtools/restart/classloader/RestartClassLoader) of the current class, org/springframework/boot/autoconfigure/thymeleaf/AbstractTemplateResolverConfiguration, and the class loader (instance of sun/misc/Launcher$AppClassLoader) for the method's defining class, org/thymeleaf/spring4/templateresolver/SpringResourceTemplateResolver, have different Class objects for the type org/springframework/context/ApplicationContext used in the signature
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
... 24 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$ThymeleafDefaultConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultTemplateResolver' defined in class path resource [org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration$Thymeleaf3Configuration$DefaultTemplateResolverConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver]: Factory method 'defaultTemplateResolver' threw exception; nested exception is java.lang.LinkageError: loader constraint violation: when resolving method "org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver.setApplicationContext(Lorg/springframework/context/ApplicationContext;)V" the class loader (instance of org/springframework/boot/devtools/restart/classloader/RestartClassLoader) of the current class, org/springframework/boot/autoconfigure/thymeleaf/AbstractTemplateResolverConfiguration, and the class loader (instance of sun/misc/Launcher$AppClassLoader) for the method's defining class, org/thymeleaf/spring4/templateresolver/SpringResourceTemplateResolver, have different Class objects for the type org/springframework/context/ApplicationContext used in the signature
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:189) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1193) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1095) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:372) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
... 37 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultTemplateResolver' defined in class path resource [org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration$Thymeleaf3Configuration$DefaultTemplateResolverConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver]: Factory method 'defaultTemplateResolver' threw exception; nested exception is java.lang.LinkageError: loader constraint violation: when resolving method "org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver.setApplicationContext(Lorg/springframework/context/ApplicationContext;)V" the class loader (instance of org/springframework/boot/devtools/restart/classloader/RestartClassLoader) of the current class, org/springframework/boot/autoconfigure/thymeleaf/AbstractTemplateResolverConfiguration, and the class loader (instance of sun/misc/Launcher$AppClassLoader) for the method's defining class, org/thymeleaf/spring4/templateresolver/SpringResourceTemplateResolver, have different Class objects for the type org/springframework/context/ApplicationContext used in the signature
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:1316) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1282) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveMultipleBeans(DefaultListableBeanFactory.java:1180) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1096) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
... 59 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver]: Factory method 'defaultTemplateResolver' threw exception; nested exception is java.lang.LinkageError: loader constraint violation: when resolving method "org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver.setApplicationContext(Lorg/springframework/context/ApplicationContext;)V" the class loader (instance of org/springframework/boot/devtools/restart/classloader/RestartClassLoader) of the current class, org/springframework/boot/autoconfigure/thymeleaf/AbstractTemplateResolverConfiguration, and the class loader (instance of sun/misc/Launcher$AppClassLoader) for the method's defining class, org/thymeleaf/spring4/templateresolver/SpringResourceTemplateResolver, have different Class objects for the type org/springframework/context/ApplicationContext used in the signature
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
... 75 common frames omitted
Caused by: java.lang.LinkageError: loader constraint violation: when resolving method "org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver.setApplicationContext(Lorg/springframework/context/ApplicationContext;)V" the class loader (instance of org/springframework/boot/devtools/restart/classloader/RestartClassLoader) of the current class, org/springframework/boot/autoconfigure/thymeleaf/AbstractTemplateResolverConfiguration, and the class loader (instance of sun/misc/Launcher$AppClassLoader) for the method's defining class, org/thymeleaf/spring4/templateresolver/SpringResourceTemplateResolver, have different Class objects for the type org/springframework/context/ApplicationContext used in the signature
at org.springframework.boot.autoconfigure.thymeleaf.AbstractTemplateResolverConfiguration.defaultTemplateResolver(AbstractTemplateResolverConfiguration.java:70) ~[spring-boot-autoconfigure-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$Thymeleaf3Configuration$DefaultTemplateResolverConfiguration.defaultTemplateResolver(ThymeleafAutoConfiguration.java:140) ~[spring-boot-autoconfigure-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$Thymeleaf3Configuration$DefaultTemplateResolverConfiguration$$EnhancerBySpringCGLIB$$f2a7a126.CGLIB$defaultTemplateResolver$0(<generated>) ~[spring-boot-autoconfigure-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$Thymeleaf3Configuration$DefaultTemplateResolverConfiguration$$EnhancerBySpringCGLIB$$f2a7a126$$FastClassBySpringCGLIB$$7a53489b.invoke(<generated>) ~[spring-boot-autoconfigure-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358) ~[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$Thymeleaf3Configuration$DefaultTemplateResolverConfiguration$$EnhancerBySpringCGLIB$$f2a7a126.defaultTemplateResolver(<generated>) ~[spring-boot-autoconfigure-1.5.6.RELEASE.jar:1.5.6.RELEASE]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEA
SE]
... 76 common frames omitted
所以我现在必须包括所有的罐子。
希望这可能在将来帮助某人,但请参阅更新#1 ,因为这可能会在将来解决 Spring DevTools类加载器限制,但导致LiveReload服务器无法运行。
So I have to include all jars for now. Hope this might help someone in the future, but please refer to Update #1 because this might going to be solved in the future Spring DevTools classloader limitations, but that lead to LiveReload server doesn't run.
更新#1
这似乎是一个DevTools问题( 自定义重启类加载器)可能会很快修复 Spring DevTools类加载器限制一>。它是在本期 Spring Boot Dev Tools&网络流量不好玩
It seems this a DevTools issue (Customizing the restart classloader) which might be fixed soon Spring DevTools classloader limitations. It is started in this issue Spring Boot Dev Tools & Web Flow don't play nice
原始答案
我有几次同样的问题,我做了一个测试,我发现了一个奇怪的行为。
I had the same issue several times, I have done a test and I found that a weird behavior.
public class SomeModel implements Serializable {
private static final long serialVersionUID = -7967970066125990593L;
...
}
CustomFlowAction.java
CustomFlowAction.java
package app.flow;
public class CustomFlowAction {
// Note here the paramter is of type Object, just to use casting instead of using the object directly to test if I have the correct one
public boolean someAction(Object obj, RequestContext context) {
SomeModel someModel = (SomeModel) obj;
return true
}
public SomeModel prepareSomeModel() {
return new SomeModel();
}
}
(流程示例1)some-flow.xml
(Flow Example 1) some-flow.xml
这个例子是使用一个spring bean,它工作正常,someAction方法返回true。
This example is using a spring bean, it works fine and someAction method returns true.
<flow ...>
<view-state id="StateOne" model="someModel">
<transition on="next" to="StateTwo">
<evaluate expression="customFlowAction.someAction(someModel, flowRequestContext)"></evaluate>
</transition>
</view-state>
</flow>
(流程示例2)some-flow.xml
(Flow Example 2) some-flow.xml
这个例子是从SomeModel创建一个新对象并将其存储在flowScope中,然后在模板中使用它。
This example is creating a new object from SomeModel and stores it flowScope, then uses it inside the template.
<flow ...>
<on-start>
<evaluate expression="submitRequestFlowAction.prepareSomeModel()" result="flowScope.someModel"></evaluate>
</on-start>
<view-state id="StateOne" model="someModel">
<transition on="next" to="StateTwo">
<evaluate expression="customFlowAction.someAction(someModel, flowRequestContext)"></evaluate>
</transition>
</view-state>
</flow>
The output is:
The output is:
java.lang.ClassCastException: app.flow.SomeModel cannot be cast to app.flow.SomeModel
Some guys guided me to there might be another classloader involved in the issue, and one told me this:
Some guys guided me to there might be another classloader involved in the issue, and one told me this:
Note that classloader is part of class types: class A, loaded by
classloader CL1, is not the same as class A loaded by classloader CL2,
even though the actual A.class might be the same file
Note that classloader is part of class types: class A, loaded by classloader CL1, is not the same as class A loaded by classloader CL2, even though the actual A.class might be the same file
Hope this would be helpful for you and anyone else in trouble like me :)
Hope this would be helpful for you and anyone else in trouble like me :)
这篇关于无法找到SpelEvaluationException方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!