【问题标题】:Eclipse Maven Spring Project - ErrorEclipse Maven Spring 项目 - 错误
【发布时间】:2013-11-22 15:25:11
【问题描述】:

我需要帮助解决一个让我发疯的错误。
我开始学习 Java EE,并且正在浏览 youtube 上的教程。一切都很顺利,直到我来到 Spring、Hibernate、JSF 准备项目。
我在 pom.xml 项目中添加了依赖项,如下所示,但在我的配置文件中出现错误:
“构建路径不完整,找不到 org/aspectj/weaver/ 的类文件BCException”
我在谷歌上寻找答案,也在这里寻找我的问题的答案。我发现我需要添加 aspectj 依赖项,但它仍然不起作用,我遇到了同样的错误。

我在我的项目中包含了以下库:(所以我想这不是缺少库的问题)

我的 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.example.j2eeapp</groupId>
<artifactId>j2eeapplication</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>J2EE Application Example</name>

<!-- 
Prime faces helps in building themes for jsf
 -->
<repositories>
    <repository>
            <id>prime-repo</id>
            <name>PrimeFaces Maven Repository</name>
            <url>http://repository.primefaces.org</url>
    </repository>
</repositories>


<!-- 
hibernate helps manage database via java
 -->
 <dependencies>
    <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>4.1.8.Final</version>
    </dependency>
    <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>4.2.0.Final</version>
    </dependency>     
    <dependency>
            <groupId>aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
            <version>1.5.2</version>
    </dependency>      
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.8.2</version>
        <scope>test</scope>
    </dependency>
 <!-- 
Spring Web flow is specifically designed to implement complex page flows. 
It is an extension of Spring MVC and a tool 
to specify page navigation rules and manage navigation.
 -->
    <dependency>
            <groupId>org.springframework.webflow</groupId>
            <artifactId>spring-webflow</artifactId>
            <version>2.3.1.RELEASE</version>
    </dependency>
 <!-- 
The Spring Faces module comes with a set of components, 
which are provided through a tag library.
 -->
    <dependency>
            <groupId>org.springframework.webflow</groupId>
            <artifactId>spring-faces</artifactId>
            <version>2.3.1.RELEASE</version>
    </dependency>
    <dependency>
            <groupId>org.springframework.webflow</groupId>
            <artifactId>spring-js</artifactId>
            <version>2.0.9.RELEASE</version>
    </dependency>
    <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>3.1.1.RELEASE</version>
    </dependency>
    <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc14</artifactId>
            <version>10.2.0.1.0</version>
    </dependency>
    <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.16</version>
    </dependency>
    <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-impl</artifactId>
            <version>2.1.10</version>
    </dependency>
    <dependency>
            <groupId>com.sun.facelets</groupId>
            <artifactId>jsf-facelets</artifactId>
            <version>1.1.14</version>
    </dependency>
    <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-api</artifactId>
            <version>2.1.10</version>
    </dependency>
    <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>20030825.184428</version>
    </dependency>
    <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.6.4</version>
    </dependency>
    <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
            <scope>provided</scope>
    </dependency>
    <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>3.0.5.RELEASE</version>
    </dependency>
    <dependency>
            <groupId>xml-apis</groupId>
            <artifactId>xml-apis</artifactId>
            <version>1.3.02</version>
    </dependency>
    <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <version>3.1.3.RELEASE</version>
    </dependency>
    <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
            <version>3.1.3.RELEASE</version>
    </dependency>
    <dependency>
            <groupId>org.primefaces</groupId>
                    <artifactId>primefaces</artifactId>
            <version>3.4</version>
    </dependency>
    <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib</artifactId>
            <version>2.2.2</version>
            <scope>runtime</scope>
    </dependency>
    <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>4.1.8.Final</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>3.1.1.RELEASE</version>
    </dependency>


  </dependencies>
  <--
     This is what I added, after I read some answer to my question on stackoverflow. Doesn't work me.
  -->
  <build>
    <plugins>
                <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>aspectj-maven-plugin</artifactId>
        <version>1.4</version>
        <configuration>
            <showWeaveInfo>true</showWeaveInfo>
            <source>1.7.0</source>
            <target>1.7.0</target>
            <Xlint>ignore</Xlint>
            <complianceLevel>1.7.0</complianceLevel>
            <encoding>UTF-8</encoding>
            <verbose>false</verbose>
            <aspectLibraries>
                <aspectLibrary>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-aspects</artifactId>
                </aspectLibrary>
            </aspectLibraries>
        </configuration>
        <dependencies>
            <dependency>
                <groupId>org.aspectj</groupId>
                <artifactId>aspectjrt</artifactId>
                <version>1.7.0</version>
            </dependency>
            <dependency>
                <groupId>org.aspectj</groupId>
                <artifactId>aspectjtools</artifactId>
                <version>1.7.0</version>
            </dependency>
        </dependencies>
    </plugin>
    </plugins>
</build>
    </project>

在这里您可以看到其中一个包含错误的文件:(我删除了 xml 声明并在发生错误的地方添加了 cmets)

    <!-- HERE -->               
    <bean id="jpaFlowExecutionListener"   class="org.springframework.webflow.persistence.JpaFlowExecutionListener">
            <constructor-arg ref="entityManagerFactory" />
            <constructor-arg ref="transactionManager" />
    </bean>
     <!-- HERE -->
    <bean id="facesContextListener" class="org.springframework.faces.webflow.FlowFacesContextLifecycleListener" />

    <webflow:flow-executor id="flowExecutor">
            <webflow:flow-execution-listeners>
                    <webflow:listener ref="jpaFlowExecutionListener" />
                    <webflow:listener ref="facesContextListener"/>
                    <webflow:listener ref="securityFlowExecutionListener"/>
            </webflow:flow-execution-listeners>
    </webflow:flow-executor>                        
    <!-- HERE -->
    <webflow:flow-registry id="flowRegistry" flow-builder-services="facesFlowBuilderServices" base-path="/WEB-INF/flows">
            <webflow:flow-location-pattern value="/**/*-flow.xml" />
    </webflow:flow-registry>

    <faces:flow-builder-services id="facesFlowBuilderServices" development="true" />

    <faces:resources />
    <!-- HERE -->
    <bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
            <property name="order" value="1"/>
            <property name="flowRegistry" ref="flowRegistry" />
            <property name="defaultHandler">
    <!-- HERE -->             
    <bean class="org.springframework.web.servlet.mvc.UrlFilenameViewController" />
            </property>
    </bean>
    <!-- HERE -->
    <bean class="org.springframework.faces.webflow.JsfFlowHandlerAdapter">
            <property name="flowExecutor" ref="flowExecutor" />
    </bean>
    <!-- HERE -->
    <bean id="faceletsViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
            <property name="viewClass" value="org.springframework.faces.mvc.JsfView"/>
            <property name="prefix" value="/WEB-INF/" />
            <property name="suffix" value=".xhtml" />
    </bean>
    <!-- HERE -->
    <bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" />

非常感谢您的帮助。


我在课堂上检查过 Benzonico,如果 BCExcepction 可见,似乎是。 我还添加了外部 jars aspectj 和 xwork,但它仍然无法正常工作。

问题很奇怪,因为在eclipse左侧的资源管理器选项卡上,当您检查时您会发现类名中没有放置错误。现在在放置代码的 Eclipse 中心,您可以看到出现了该问题。

我仍然需要这个问题的帮助。有人吗?

【问题讨论】:

    标签: java spring maven jakarta-ee


    【解决方案1】:

    这并不能直接解决您的问题,但会帮助您解决问题:

    您可以做两件事来检查您丢失的类是否在项目的类路径中:

    在 Eclipse 中:按 ctrl+shift+t 并输入你的类的名称,如果它没有出现,那么它是不在您的课程路径中。

    您还可以使用 findjar 检查哪个 jar 是您的类,并验证该 jar 是否在您的类路径中。

    【讨论】:

      【解决方案2】:

      有时,导入库的顺序很重要,请尝试让您的应用更早地加载库。如果您使用 eclipse,请检查构建路径配置、导入顺序。

      【讨论】:

        猜你喜欢
        • 2015-02-09
        • 2012-08-08
        • 2020-04-15
        • 2011-11-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-10-21
        相关资源
        最近更新 更多