【问题标题】:spring 3.2 configuration tx:annotation-driven error in eclipsespring 3.2 configuration tx:annotation-driven error in eclipse
【发布时间】:2013-08-11 13:56:51
【问题描述】:

尝试从 Spring 3.0 -> 3.2.4 迁移

使用:Eclipse Juno(在 64 位 java 1.7 上)和 STS 3.3,

问题:Eclipse/STS IDE 中的编辑窗口显示:

处理 XML 时发生错误 'org/springframework/aop/config/AopNamespaceUtils'

在我使用<tx:annotation-driven>的线路上

编译项目会导致类似的错误。

java.lang.NoClassDefFoundError: org/springframework/aop/config/AopNamespaceUtils

我一直在努力寻找解决方案。我假设这是我忽略的简单事情,但我终生无法找到它。

这是我到目前为止所做的:

  • 我已经使用 Eclipse 从头开始​​创建了配置文件 -> 新文件 -> STS bean 配置。
  • 我已确认 maven 已将适当的 jar 安装到 类路径。
  • 我已经用 java 版本 1.6 和 1.7 编译过
  • 使用 -clean 启动 eclipse(以防旧项目和工作区版本留下任何工件)
  • <tx:annotation-driven> 是使用普通的 Eclipse ctrl+space 添加的
  • 在 pom.xml 中显式添加了 spring-web(Spring 3.2 版删除了所需的依赖项,但无论进出都没有区别)
  • 在 pom.xml 中显式添加 spring-aop

任何帮助或见解将不胜感激。

这是我的 config-portlets.xml(之前的版本在 Spring 3.0 中工作)

    <?xml version="1.0" encoding="UTF-8"?>
    <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:mvc="http://www.springframework.org/schema/mvc"     xmlns:p="http://www.springframework.org/schema/p"
        xmlns:tx="http://www.springframework.org/schema/tx"     xmlns:util="http://www.springframework.org/schema/util"
        xsi:schemaLocation="http://www.springframework.org/schema/beans     http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/context     http://www.springframework.org/schema/context/spring-context-3.2.xsd
            http://www.springframework.org/schema/mvc     http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd">

    <tx:annotation-driven />  <!-- error here-->
</beans>

我已在我的 pom.xml 中明确包含 spring-aop-3.2.4.Final

    <?xml version="1.0"?>

    <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.sbeko</groupId>
        <artifactId>horse-accounts</artifactId>
        <packaging>war</packaging>
        <name>horse-accounts Portlet</name>
        <version>0.0.1-SNAPSHOT</version>
        <build>
            <plugins>...
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.5</version>
                    <configuration>
                        <encoding>UTF-8</encoding>
                        <source>1.6</source> <!-- 1.7 tried here as well -->
                        <target>1.6</target>
                    </configuration>
                </plugin>
                <plugin>
 <!-- bunch of stuff taken out for clarity..-->
            </plugin>
            </plugins>
        </build>
        <dependencies>
            <dependency>
<!--  bunch of stuff taken out for clarity..-->
        </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-webmvc-portlet</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <dependency>
                <groupId>org.aspectj</groupId>
                <artifactId>aspectjrt</artifactId>
                <version>1.6.8</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-orm</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-test</artifactId>
                <version>${spring.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>servlet-api</artifactId>
                <version>2.4</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>javassist</groupId>
                <artifactId>javassist</artifactId>
                <version>3.9.0.GA</version>
            </dependency>
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>5.1.25</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>commons-dbcp</groupId>
                <artifactId>commons-dbcp</artifactId>
                <version>1.2.2</version>
            </dependency>
            <dependency>
                <groupId>javax.validation</groupId>
                <artifactId>validation-api</artifactId>
                <version>1.1.0.Final</version>
            </dependency>
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-validator</artifactId>
                <version>5.0.1.Final</version>
            </dependency>
            <dependency>
                <groupId>cglib</groupId>
                <artifactId>cglib</artifactId>
                <version>3.0</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-aspects</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <dependency>
                <groupId>javax.portlet</groupId>
                <artifactId>portlet-api</artifactId>
                <version>2.0</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>com.thoughtworks.xstream</groupId>
                <artifactId>xstream</artifactId>
                <version>1.4.4</version>
            </dependency>
            <dependency>
                <groupId>joda-time</groupId>
                <artifactId>joda-time</artifactId>
                <version>1.6.2</version>
            </dependency>
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-envers</artifactId>
                <version>${hibernate.version}</version>
            </dependency>
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-entitymanager</artifactId>
                <version>${hibernate.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
                <version>3.2.3.RELEASE</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-aop</artifactId>
                <version>${spring.version}</version>
            </dependency>
        </dependencies>
        <properties>
            <spring.version>3.2.4.RELEASE</spring.version>
            <hibernate.version>3.5.6-Final</hibernate.version>
        </properties>
    </project>

【问题讨论】:

  • 能否使用 pom.xml 文件中的 eclipse 'dependency hierarchy' 选项卡并检查 spring 上是否存在低于 3.2.x 版本的依赖项?有时您会从其他依赖项(尤其是 spring portlet)中找到可能导致某些类路径问题的较低版本。
  • 我检查了所有 spring 依赖项,并且通常清理了我的 pom - 除了最低级别的 jar 之外,我删除了所有对 spring 的引用。例如,使用 spring-webmvc-portlet 让 maven 引入更高级别的依赖项。找不到任何东西
  • 如果将 Spring Nature 添加到项目中会发生什么?
  • 自我以前的版本以来,我已经启用了 Spring Nature - 在 JEE 视角下的项目资源管理器中根本不显示 bean - 清楚地表明某些东西被破坏了。这有一种冲突的感觉,但很难知道如何开始解决这个问题。我确实尝试打开一个新工作区(但复制了布局),但我仍然遇到同样的问题。它指向更深层次的东西。
  • 您可以尝试使用 Spring MVC 模板和 Spring 3.2.4 创建一个新的 Spring 项目。然后找到配置文件并添加 并让我知道会发生什么 - 这将帮助我确定这是我的设置还是更广泛的设置。

标签: spring eclipse-plugin migration spring-aop spring-transactions


【解决方案1】:

Eclipse/Java/PC 出现无法理解的故障。我唯一的答案是:让电脑开机过夜,不要触摸它,它会自行修复。也许,在取出电池后重新启动会导致相同的结果。

我只能怀疑发生了一些垃圾收集,它清除了 Java 和/或 Eclipse 中的损坏。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-02
    • 1970-01-01
    • 1970-01-01
    • 2013-06-29
    • 2012-01-09
    相关资源
    最近更新 更多