java - Eclipse Maven Spring 项目 - 错误

标签 java spring maven jakarta-ee

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

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

我的 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声明并在发生错误的地方添加了注释)

    <!-- 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 我检查了我的类(class),如果 BCExcepction 可见,看起来确实如此。 我还添加了外部 jarsspectj 和 xwork,但它仍然不起作用。

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

enter image description here

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

最佳答案

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

您可以执行两件事来检查缺少的类是否位于项目的类路径中:

在 Eclipse 中:按 ctrl+shift+t 并输入类的名称,如果没有显示,则为不在你的类(class)路径中。

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

关于java - Eclipse Maven Spring 项目 - 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19895981/

相关文章:

java - Selenium 不使用 InternetExplorerDriver 单击按钮的解决方法

java - Spring Security 中 JSON 的主要对象

Java,改变变量值

java - 在eclipse中使用maven创建spring mvc项目

java - Maven编译错误: (use -source 7 or higher to enable diamond operator)

java - 仅允许插件存储库?

java - 使用元注释触发注释处理器

java - Spring Boot 中 YAML 处理器(Jackson、SnakeYAML)的值转换错误

java - Spring Advice 不适用于递归 bean

java - 如何在springframework中查找注解的文档