1、配置类中的ShiroDialect相关

ShiroConfig配置ShiroDialect如图所示:
image.png

启动报以下下错误:

  1. Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
  2. 2019-06-19 14:53:04.035 ERROR 7548 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
  3. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'getShiroDialect' defined in class path resource [com/ck/syscheck/config/ShiroConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [at.pollux.thymeleaf.shiro.dialect.ShiroDialect]: Factory method 'getShiroDialect' threw exception; nested exception is java.lang.NoClassDefFoundError: org/thymeleaf/processor/attr/AbstractTextChildModifierAttrProcessor
  4. at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:627) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
  5. at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:456) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
  6. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1321) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
  7. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1160) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
  8. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
  9. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
  10. at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
  11. at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
  12. at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
  13. at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
  14. at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:843) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
  15. at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877) ~[spring-context-5.1.7.RELEASE.jar:5.1.7.RELEASE]
  16. at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.1.7.RELEASE.jar:5.1.7.RELEASE]
  17. at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) ~[spring-boot-2.1.5.RELEASE.jar:2.1.5.RELEASE]
  18. at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) [spring-boot-2.1.5.RELEASE.jar:2.1.5.RELEASE]
  19. at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.1.5.RELEASE.jar:2.1.5.RELEASE]
  20. at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) [spring-boot-2.1.5.RELEASE.jar:2.1.5.RELEASE]
  21. at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) [spring-boot-2.1.5.RELEASE.jar:2.1.5.RELEASE]
  22. at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) [spring-boot-2.1.5.RELEASE.jar:2.1.5.RELEASE]
  23. at com.ck.syscheck.SysCheckApplication.main(SysCheckApplication.java:12) [classes/:na]
  24. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_162]
  25. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_162]
  26. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_162]
  27. at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_162]
  28. at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.1.5.RELEASE.jar:2.1.5.RELEASE]
  29. Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [at.pollux.thymeleaf.shiro.dialect.ShiroDialect]: Factory method 'getShiroDialect' threw exception; nested exception is java.lang.NoClassDefFoundError: org/thymeleaf/processor/attr/AbstractTextChildModifierAttrProcessor
  30. at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
  31. at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:622) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
  32. ... 24 common frames omitted
  33. Caused by: java.lang.NoClassDefFoundError: org/thymeleaf/processor/attr/AbstractTextChildModifierAttrProcessor
  34. at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_162]
  35. at java.lang.ClassLoader.defineClass(ClassLoader.java:763) ~[na:1.8.0_162]
  36. at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.8.0_162]
  37. at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) ~[na:1.8.0_162]
  38. at java.net.URLClassLoader.access$100(URLClassLoader.java:73) ~[na:1.8.0_162]
  39. at java.net.URLClassLoader$1.run(URLClassLoader.java:368) ~[na:1.8.0_162]
  40. at java.net.URLClassLoader$1.run(URLClassLoader.java:362) ~[na:1.8.0_162]
  41. at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_162]
  42. at java.net.URLClassLoader.findClass(URLClassLoader.java:361) ~[na:1.8.0_162]
  43. at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_162]
  44. at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338) ~[na:1.8.0_162]
  45. at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_162]
  46. at at.pollux.thymeleaf.shiro.dialect.ShiroDialect.<clinit>(ShiroDialect.java:32) ~[thymeleaf-extras-shiro-1.2.1.jar:na]
  47. at com.ck.syscheck.config.ShiroConfig.getShiroDialect(ShiroConfig.java:87) ~[classes/:na]
  48. at com.ck.syscheck.config.ShiroConfig$$EnhancerBySpringCGLIB$$d834d746.CGLIB$getShiroDialect$2(<generated>) ~[classes/:na]
  49. at com.ck.syscheck.config.ShiroConfig$$EnhancerBySpringCGLIB$$d834d746$$FastClassBySpringCGLIB$$e44a9e2.invoke(<generated>) ~[classes/:na]
  50. at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.1.7.RELEASE.jar:5.1.7.RELEASE]
  51. at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:363) ~[spring-context-5.1.7.RELEASE.jar:5.1.7.RELEASE]
  52. at com.ck.syscheck.config.ShiroConfig$$EnhancerBySpringCGLIB$$d834d746.getShiroDialect(<generated>) ~[classes/:na]
  53. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_162]
  54. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_162]
  55. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_162]
  56. at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_162]
  57. at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
  58. ... 25 common frames omitted
  59. Caused by: java.lang.ClassNotFoundException: org.thymeleaf.processor.attr.AbstractTextChildModifierAttrProcessor
  60. at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_162]
  61. at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_162]
  62. at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338) ~[na:1.8.0_162]
  63. at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_162]
  64. ... 49 common frames omitted
  65. Process finished with exit code 0

解决办法:
将POM.xml文件的 thymeleaf-extras-shiro1.2.1改成2.0.0版本即可。

  1. <dependency>
  2. <groupId>com.github.theborakompanioni</groupId>
  3. <artifactId>thymeleaf-extras-shiro</artifactId>
  4. <version>1.2.1</version>
  5. </dependency>

改成2.0.0,如下以下:

  1. <dependency>
  2. <groupId>com.github.theborakompanioni</groupId>
  3. <artifactId>thymeleaf-extras-shiro</artifactId>
  4. <version>2.0.0</version>
  5. </dependency>

问题得以解决。