Eclipse Maven Spring项目 - 错误 [英] Eclipse Maven Spring Project - Error

查看:153
本文介绍了Eclipse Maven Spring项目 - 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要帮助解决让我发疯的错误。

我开始学习Java EE,我正在浏览youtube上的教程。一切顺利,直到我来到Spring,Hibernate,JSF准备项目。

我在我的pom.xml项目中添加了依赖项,就像你在下面看到的那样,但在我的配置文件中我遇到了一个错误:

构建路径不完整无法找到org / aspectj / weaver / BCException的类文件

我在谷歌上寻找并在这里寻求答案回答我的问题。我发现我需要添加aspectj依赖项,但它仍然无效并且我遇到了同样的错误。


我在我的项目中包含了以下库:(所以我猜它不是缺少图书馆的问题)





我的pom.xml文件:

I need help with an error which make me crazy.
I started to study Java EE and I am going through tutorial on youtube. Everything went well till I came to Spring, Hibernate, JSF preparing project.
I added dependencies to my pom.xml project like you can see below, but in my config files I am having an error:
"Build path is incomplete can't find class file for org/aspectj/weaver/BCException"
I was looking on google and also here for an answer answer to my question. I found that I need to add aspectj dependency, but still it doesn't work and I am having the same error.

I included following libaries to my project: (So I guess its not a problem with missing libary)

My pom.xml file:

<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声明并添加了发生错误的地方的评论)

And here you can see one of the files which contains an error: ( I deleted xml declaration and added comments in the place when an error occurred)

    <!-- 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" />

我真的很感谢你的帮助。

I would really appreciate your help.

Benzonico我检查了我的课程,如果BCExcepction可见,似乎是。
另外我添加了外部jars aspectj和xwork,它仍然不起作用。

Benzonico I checked in my classes, if BCExcepction is visible, seems it is. Also I added externals jars aspectj and xwork and it still doesn't work.

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

The problem is weird imo, since on the explorer tab on the left side of the eclipse, when you check you will find that there is no error placed in the class name. Now in the center of the eclipse where code is placed you can see, that problem occurs.

我仍然需要这个问题的帮助。任何人?

Still I need help with this question. Anyone?

推荐答案

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

This does not address directly your problem but will help you to figure it out :

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

You can do two things to check that your missing class is on the classpath of your project :

在Eclipse中:按 ctrl + shift + t 并键入您的类的名称,如果它没有显示,那么它不在您的类路径中。

In Eclipse : press ctrl+shift+t and type the name of your class, if it does not show up then it is not in your class path.

您还可以使用 findjar 并确认此jar位于您的类路径上。

You can also check in which jar is your class using findjar and verify that this jar is on your classpath somewhere.

这篇关于Eclipse Maven Spring项目 - 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆