3

尝试从 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 添加
  • 将spring-web显式添加到 pom.xml (Spring 3.2 版删除了所需的依赖项,但它没有区别,进出)
  • 将spring-aop显式添加到 pom.xml

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

这是我的 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>
4

1 回答 1

-1

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

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

于 2013-08-12T13:18:18.913 回答