2013-06-14 2 views
0

* сильный текст * При выполнении Java SE + Spring приложение имеет следующую ошибку. Я нашел аналогичную проблему по intenet и на этом веб-сайте, но не смог найти правильное решение. Я думаю, что проблема в файле jar отсутствует.Spring 3.2 Кэширование Пространство именHandler для ehcache

Exception in thread "main" org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring] 
Offending resource: class path resource [Spring-Module.xml] 

    at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68) 
    at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85) 
    at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:80) 
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.error(BeanDefinitionParserDelegate.java:318) 
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1435) 
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1428) 
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:185) 
    at 

Spring.xml

<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:context="http://www.springframework.org/schema/context" 
xmlns:ehcache="http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-2.5.xsd 
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context-2.5.xsd 
    http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring 
    http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring/ehcache-spring-1.1.xsd 
    "> 

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>com.mkyong.common</groupId> 
    <artifactId>SpringExample</artifactId> 
    <packaging>jar</packaging> 
    <version>1.0-SNAPSHOT</version> 
    <name>SpringExample</name> 
    <url>http://maven.apache.org</url> 

    <dependencies> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>3.8.1</version> 
     <scope>test</scope> 
    </dependency> 

    <!-- Spring framework --> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-core</artifactId> 
     <version>3.2.2.RELEASE</version> 
    </dependency> 

    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-context</artifactId> 
     <version>3.2.2.RELEASE</version> 
    </dependency> 

    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-jdbc</artifactId> 
     <version>3.2.3.RELEASE</version> 
    </dependency> 

    <dependency> 
     <groupId>com.oracle</groupId> 
     <artifactId>ojdbc14</artifactId> 
     <version>10.2.0.3.0</version> 
    </dependency> 

    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-aspects</artifactId> 
     <version>3.2.3.RELEASE</version> 
    </dependency> 

    <dependency> 
     <groupId>net.sf.ehcache</groupId>  
     <artifactId>ehcache-core</artifactId> 
     <version>2.5.0</version> 
    </dependency> 

    </dependencies> 
</project> 

ответ

2

Вы пытаетесь использовать ehcache-spring-annotations, но я не вижу зависимость в вашем ПОМ.

Попробуйте добавить:

<dependency> 
    <groupId>com.googlecode.ehcache-spring-annotations</groupId> 
    <artifactId>ehcache-spring-annotations</artifactId> 
    <version>1.2.0</version> 
</dependency> 

Кстати, если вы хотите лет использовать встроенную поддержку Spring для @Cacheable, вам не нужна эта зависимость. Так что просто удалите

http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring 
http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring/ehcache-spring-1.1.xsd 

от вашего Spring.xml файла.

+0

при использовании встроенной поддержки Spring, как я определяю кешман. Не могли бы вы написать образец Spring.xml. –

+0

Посмотрите: http://www.javacodegeeks.com/2011/02/spring-31-cache-abstraction-tutorial.html или официальный документ: http://static.springsource.org/spring/docs/3.2 .x/spring-framework-reference/html/cache.html –

+0

http://www.briandupreez.net/2010/06/spring-aspectj-ehcache-method-caching.html ссылка хорошо для поддержки родного Spring cache –

Смежные вопросы