首页 文章

Spring Boot Starter Cache - 缺少Velocity?

提问于
浏览
3

我正在使用 ehcache 测试 Spring Boot 1.3.0.M3 并遇到了一些问题 .

当我启动应用程序后,控制台上发生异常:

线程“main”中的异常org.springframework.beans.factory.BeanCreationException:在类路径资源中定义名为'velocityConfigurer'的bean时出错[org / springframework / boot / autoconfigure / velocity / VelocityAutoConfiguration $ VelocityWebConfiguration.class]:调用init方法失败;嵌套异常是org.springframework.beans.factory上的org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)中的java.lang.NoClassDefFoundError:org / apache / velocity / runtime / log / CommonsLogLogChute . org.springframework.beans.factory.support.AbstractBeanFactory $ 1.getObject(AbstractBeanFactory)中的org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)中的support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) .java:305)org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:301)at org . org.springframework.beans.factory.supp上的springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196) org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:834)org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537)中的ort.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772) org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)org.springframework.boot.SpringApplication.refresh(SpringApplication.java:667)org.springframework.boot.SpringApplication.doRun(SpringApplication) .java:342)org.springframework.boot.SpringApplication.run(SpringApplication.java:273)org.springframework.boot.SpringApplication.run(SpringApplication.java:971)org.springframework.boot.SpringApplication.run( SpringApplication.java:960)at com.aconso.creator2.CreatorApplication.main(CreatorApplication.java:26)引起:java.lang.NoClassDefFoundError:org / apache / velocity / runt org.springframework.ui.velocity.VelocityEngineFactory.createVelocityEngine(VelocityEngineFactory.java:238)中的orme.springframework.web.servlet.view.velocity.VelocityConfigurer.afterPropertiesSet(VelocityConfigurer.java:120)中的ime / log / CommonsLogLogChute . springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)... 16更多引起:java.lang .ClassNotFoundException:org.apache.velocity.runtime.log.CommonsLogLogChute at java.net.URLClassLoader $ 1.run(URLClassLoader.java:366)at java.net.URLClassLoader $ 1.run(URLClassLoader.java:355)at java.security位于java..L.Liscuncher的java.lang.ClassLoader.loadClass(ClassLoader.java:425)java.net.URLClassLoader.findClass(URLClassLoader.java:354)的.AccessController.doPrivileged(Native Method)$ AppClassLoader.loadClass(Launcher) .ja va:308)在java.lang.ClassLoader.loadClass(ClassLoader.java:358)... 20更多

我的pom.xml:

...
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.3.0.M3</version>
</parent>
...
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-cache</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    <dependency>
        <groupId>net.sf.ehcache</groupId>
        <artifactId>ehcache</artifactId>
    </dependency>
    ...
</dependencies>
...

mvn依赖:树

org.springframework.boot:string-boot-starter-web:jar:1.3.0.M3:compile [INFO] | - org.springframework.boot:spring-boot-starter:jar:1.3.0.M3:compile [INFO] | | - org.springframework.boot:spring-boot:jar:1.3.0.M3:编译[INFO] | | - org.springframework.boot:spring-boot-autoconfigure:jar:1.3.0.M3:compile [INFO] | | - org.yaml:snakeyaml:jar:1.15:编译[INFO] | - org.springframework.boot:spring-boot-starter-validation:jar:1.3.0.M3:compile [INFO] | | - org.hibernate:hibernate-validator:jar:5.2.1.Final:compile [INFO] | | - javax.validation:validation-api:jar:1.1.0.Final:compile [INFO] | | - com.fasterxml:classmate:jar:1.1.0:compile [INFO] | - com.fasterxml.jackson.core:jackson-databind:jar:2.6.1:compile [INFO] | | - com.fasterxml.jackson.core:jackson-annotations:jar:2.6.1:compile [INFO] | | - com.fasterxml.jackson.core:jackson-core:jar:2.6.1:compile [INFO] | - org.springframework:spring-web:jar:4.2.0.RELEASE:编译[INFO] | - org.springframework:spring-webmvc:jar:4.2.0.RELEASE:compile [INFO] | - org.springframework:spring-expression:jar:4.2.0.RELEASE:compile [INFO] - org.springframework.boot:spring-boot-starter-tomcat:jar:1.3.0.M3:提供[INFO] | - org.apache.tomcat.embed:tomcat-embed-core:jar:8.0.23:提供[INFO] | - org.apache.tomcat.embed:tomcat-embed-el:jar:8.0.23:compile [INFO] | - org.apache.tomcat.embed:tomcat-embed-logging-juli:jar:8.0.23:提供[INFO] | - org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.0.23:提供[INFO] - org.springframework.boot:spring-boot-starter-cache:jar:1.3.0.M3:compile [信息] | - org.springframework:spring-context:jar:4.2.0.RELEASE:compile [INFO] | - org.springframework:spring-context-support:jar:4.2.0.RELEASE:compile [INFO] - org.springframework.boot:spring-boot-starter-security:jar:1.3.0.M3:compile [INFO] | - org.springframework:spring-aop:jar:4.2.0.RELEASE:compile [INFO] | | - aopalliance:aopalliance:jar:1.0:编译[INFO] | - org.springframework.security:spring-security-config:jar:4.0.2.RELEASE:compile [INFO] | - org.springframework.security:spring-security-web:jar:4.0.2.RELEASE:compile [INFO] - org.springframework.security:spring-security-cas:jar:4.0.2.RELEASE:compile [INFO] | - org.jasig.cas.client:cas-client-core:jar:3.3.3:compile [INFO] | | - org.opensaml:opensaml:jar:2.5.1-1:compile [INFO] | | - org.opensaml:openws:jar:1.4.2-1:编译[INFO] | | | - org.opensaml:xmltooling:jar:1.3.2-1:compile [INFO] | | | | - org.slf4j:log4j-over-slf4j:jar:1.7.12:compile [INFO] | | | | - joda-time:joda-time:jar:2.8.1:编译[INFO] | | | | - org.bouncycastle:bcprov-jdk15:jar:1.45:compile [INFO] | | | | - org.apache.santuario:xmlsec:jar:1.4.4:编译[INFO] | | | | - ca.juliusdavies:not-yet-commons-ssl:jar:0.3.9:compile [INFO] | | | | - net.jcip:jcip-annotations:jar:1.0:compile [INFO] | | | - commons-codec:commons-codec:jar:1.3:compile [INFO] | | | - commons-httpclient:commons-httpclient:jar:3.1:compile [INFO] | | - commons-collections:commons-collections:jar:3.2.1:compile [INFO] | | - commons-lang:commons-lang:jar:2.1:compile [INFO] | | - velocity:velocity:jar:1.5:编译[INFO] | | - org.owasp.esapi:esapi:jar:2.0GA:编译[INFO] | | - xml-apis:xml-apis:jar:1.4.01:编译[INFO] | | - xerces:xercesImpl:jar:2.10.0:runtime [INFO] | | - xml-resolver:xml-resolver:jar:1.2:runtime [INFO] | | - xalan:xalan:jar:2.7.1:runtime [INFO] | | - xalan:serializer:jar:2.7.1:runtime [INFO] | - org.springframework.security:spring-security-core:jar:4.0.2.RELEASE:compile [INFO] | - org.springframework:spring-beans:jar:4.2.0.RELEASE:compile [INFO] | - org.springframework:spring-core:jar:4.2.0.RELEASE:compile [INFO] - org.springframework.boot:spring-boot-starter-thymeleaf:jar:1.3.0.M3:compile [INFO] | - org.thymeleaf:thymeleaf-spring4:jar:2.1.4.RELEASE:compile [INFO] | - nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:jar:1.2.9:compile [INFO] - org.thymeleaf.extras:thymeleaf-extras-springsecurity4:jar:2.1.2.RELEASE:compile [INFO] | - org.thymeleaf:thymeleaf:jar:2.1.4.RELEASE:compile [INFO] | | - ognl:ognl:jar:3.0.8:编译[INFO] | | - org.javassist:javassist:jar:3.18.1-GA:编译[INFO] | | - org.unbescape:unbescape:jar:1.1.0.RELEASE:编译[INFO] | - org.slf4j:slf4j-api:jar:1.7.12:compile [INFO] - org.springframework.boot:spring-boot-starter-log4j2:jar:1.3.0.M3:compile [INFO] | - org.apache.logging.log4j:log4j-slf4j-impl:jar:2.3:compile [INFO] | - org.apache.logging.log4j:log4j-api:jar:2.3:compile [INFO] | - org.apache.logging.log4j:log4j-core:jar:2.3:compile [INFO] | - org.slf4j:jcl-over-slf4j:jar:1.7.12:compile [INFO] | - org.slf4j:jul-to-slf4j:jar:1.7.12:compile [INFO] - org.springframework.boot:spring-boot-starter-actuator:jar:1.3.0.M3:compile [INFO] | - org.springframework.boot:spring-boot-actuator:jar:1.3.0.M3:compile [INFO] - org.springframework.boot:spring-boot-starter-data-jpa:jar:1.3.0.M3:编译[INFO] | - org.springframework.boot:spring-boot-starter-aop:jar:1.3.0.M3:compile [INFO] | | - org.aspectj:aspectjrt:jar:1.8.6:编译[INFO] | | - org.aspectj:aspectjweaver:jar:1.8.6:编译[INFO] | - org.springframework.boot:spring-boot-starter-jdbc:jar:1.3.0.M3:compile [INFO] | | - org.apache.tomcat:tomcat-jdbc:jar:8.0.23:compile [INFO] | | | - org.apache.tomcat:tomcat-juli:jar:8.0.23:编译[INFO] | | - org.springframework:spring -jdbc:jar:4.2.0.RELEASE:compile [INFO] | - org.hibernate:hibernate-entitymanager:jar:4.3.10.Final:compile [INFO] | | - org.jboss.logging:jboss-logging:jar:3.1.3.GA:compile [INFO] | | - org.jboss.logging:jboss-logging-annotations:jar:1.2.0.Beta1:compile [INFO] | | - org.hibernate:hibernate-core:jar:4.3.10.Final:compile [INFO] | | | - antlr:antlr:jar:2.7.7:编译[INFO] | | | - org.jboss:jandex:jar:1.1.0.Final:compile [INFO] | | - dom4j:dom4j:jar:1.6.1:编译[INFO] | | - org.hibernate.common:hibernate-commons-annotations:jar:4.0.5.Final:compile [INFO] | | - org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile [INFO] | - javax.transaction:javax.transaction-api:jar:1.2:compile [INFO] | - org.springframework.data:spring-data-jpa:jar:1.9.0.RC1:compile [INFO] | | - org.springframework.data:spring-data-commons:jar:1.11.0.RC1:compile [INFO] | | - org.springframework:spring-orm:jar:4.2.0.RELEASE:compile [INFO] | | - org.springframework:spring-tx:jar:4.2.0.RELEASE:compile[INFO] | - org.springframework:spring-aspects:jar:4.2.0.RELEASE:compile [INFO] - org.hsqldb:hsqldb:jar:2.3.3:runtime [INFO] - org.springframework.boot:spring-boot-starter -test:jar:1.3.0.M3:test [INFO] | - junit:junit:jar:4.12:test [INFO] | - org.mockito:mockito-core:jar:1.10.19:test [INFO] | | - org.objenesis:objenesis:jar:2.1:test [INFO] | - org.hamcrest:hamcrest-core:jar:1.3:test [INFO] | - org.hamcrest:hamcrest-library:jar:1.3:test [INFO] | - org.springframework:spring-test:jar:4.2.0.RELEASE:test [INFO] - org.webjars:angularjs:jar:1.4.2:compile [INFO] - org.webjars:jquery:jar:2.1.4 :compile [INFO] - org.webjars:bootstrap:jar:3.3.5:compile [INFO] - org.webjars:angular-file-upload:jar:5.0.0:compile [INFO] - net.sf.jtidy: jtidy:jar:r938:compile [INFO] - org.jsoup:jsoup:jar:1.8.2:compile [INFO] - net.sf.ehcache:ehcache:jar:2.10.0:compile

我的类路径中有一个ehcache.xml,并且实例化了EHCacheManager . 当我删除spring-boot-starter-cache-和ehcache-dependency时,一切都很顺利 . (但只有ConcurrentMapCacheManager)

Question:

我是否需要使用spring-boot-starter-cache的速度,还是有其他缺失或错误的东西?

3 回答

  • 4

    根据速度,我遇到了与spring-security-cas相同的问题 . 您可以通过添加来解决问题

    @EnableAutoConfiguration(exclude = VelocityAutoConfiguration.class)
    

    到你的 Spring 季启动应用程序主类

  • 6

    使用最新版本的Spring Boot,您可以这样做 -

    @SpringBootApplication(exclude = VelocityAutoConfiguration.class)
    
  • 0

    如果类路径中存在这两个类,则 VelocityAutoConfiguration 才会启动:

    @ConditionalOnClass({ VelocityEngine.class, VelocityEngineFactory.class })
    

    它们分别来自 org.apache.velocity:velocityorg.springframework:spring-context-support .

    您可以通过以下方式确定哪些依赖项可以将这些依赖项传递给项目:

    mvn dependency:tree

相关问题