首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么maven编译器不能从depedency中解析类?

为什么maven编译器不能从depedency中解析类?
EN

Stack Overflow用户
提问于 2010-08-23 11:34:49
回答 1查看 1.1K关注 0票数 1

Eclipse可以构建这个项目,依赖jar在本地存储库中,编译器列出jar。我正在使用Eclipse Helios和Maven Integration For Eclipse (0.10.2);

但是它失败了,因为编译器不能从PropertiesEditor -beans-2.5.6.jar中解析出来。

以下是构建过程的完整报告

http://wellingtonpeoplescentre.org.nz/geek/maven-wigout.txt

这是我的POM。

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<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>witerat</groupId>
 <artifactId>iWPC</artifactId>
 <packaging>war</packaging>
 <version>0.0.1-SNAPSHOT</version>
 <name>WPC on the web</name>
 <url>http://wellingtonpeoplescentre.org.nz</url>
 <organization>
  <name>Wellington People's Centre</name>
  <url>http://wellingtonpeoplescentre.org.nz</url>
 </organization>


 <build>
  <defaultGoal>package</defaultGoal>
  <finalName>iBffsdb</finalName>
  <sourceDirectory>src/main/java</sourceDirectory>
  <testSourceDirectory>src/test/java</testSourceDirectory>
  <directory>target</directory>  
  <resources>
   <resource>
    <directory>src/main/resources</directory>
   </resource>
  </resources>
  <testResources>
   <testResource>
    <directory>src/test/resources</directory>
   </testResource>
  </testResources>
  <plugins>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>

    <version>2.1-beta-1</version>
    <configuration>
    <overlays>
    <!-- 
      <overlay>      
       <groupId>org.dojotoolkit</groupId>       
       <artifactId>dojo-war</artifactId>
       <targetPath>javascript</targetPath>
      </overlay> -->
      <overlay>
       <groupId>jcivicrm-dao</groupId>
       <artifactId>jcivicrm-dao</artifactId>
       <type>jar</type>
       <targetPath>WEB-INF/classes</targetPath>
      </overlay>
    </overlays>
    <warSourceDirectory>WebContent</warSourceDirectory>
    </configuration>
   </plugin>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.3.1</version>
    <configuration>
        <encoding>Cp1252</encoding>


     <verbose>true</verbose>    
     <source>1.6</source>
     <target>1.6</target>
    </configuration>
   </plugin>

  </plugins>
 </build>
 <repositories>
  <repository>
   <id>snapshots-local</id>
   <name>snaps</name>
   <url>http://localhost:12120/nexus-webapp-1.7.1/content/repositories/snapshots/</url>
   <releases>
    <enabled>false</enabled>
   </releases>
   <snapshots>
     <enabled>true</enabled>
    <updatePolicy>always</updatePolicy>
    <checksumPolicy>warn</checksumPolicy>
   </snapshots>
  </repository>
 </repositories>
 <dependencies>
  <dependency>
   <groupId>jcivicrm-dao</groupId>
   <artifactId>jcivicrm-dao</artifactId>
   <version>0.0.1-SNAPSHOT</version>
  </dependency><dependency>
   <groupId>JCivicrm-platform</groupId>
   <artifactId>JCivicrm-platform</artifactId>
   <version>0.0.1-SNAPSHOT</version>
  </dependency><dependency>
   <groupId>JCiviCRM</groupId>
   <artifactId>JCiviCRM</artifactId>
   <version>0.0.1-SNAPSHOT</version>
  </dependency><dependency>
   <groupId>nz.org.wpc.user.security</groupId>
   <artifactId>nz.org.wpc.user.security</artifactId>
   <version>0.0.1-SNAPSHOT</version>
    </dependency><dependency>
   <groupId>com.h2database</groupId>
   <artifactId>h2</artifactId>
   <version>1.1.111</version>
  </dependency><dependency>
   <groupId>commons-collections</groupId>
   <artifactId>commons-collections</artifactId>
   <version>3.2.1</version>
  </dependency><dependency>
   <groupId>commons-dbcp</groupId>
   <artifactId>commons-dbcp</artifactId>
   <version>1.2.2</version>
  </dependency><dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>servlet-api</artifactId>
   <version>2.4</version> 
   <scope>provided</scope>
  </dependency><dependency>
   <groupId>javax</groupId>
   <artifactId>mail</artifactId>
   <version>1.5</version>
   <scope>system</scope>
   <systemPath>c:\sun\sdk\lib\mail.jar</systemPath>
  </dependency><dependency>
   <groupId>javax.transaction</groupId>
   <artifactId>jta</artifactId>
   <version>1.0.1B</version>
  </dependency><dependency>
   <groupId>junit</groupId>
   <artifactId>junit</artifactId>
   <version>3.8.2</version>
   <scope>system</scope>
   <systemPath>C:\dev\eclipse\plugins\org.junit_3.8.2.v20080602-1318\junit.jar</systemPath>
  </dependency><dependency>
     <groupId>net.sf.ehcache</groupId>
     <artifactId>ehcache</artifactId>
     <version>1.6.0</version>
    </dependency><dependency>
   <groupId>net.sf.json-lib</groupId>
   <artifactId>json-lib-ext-spring</artifactId>
   <version>1.0.2</version>
  </dependency><dependency>
     <groupId>org.aspectj</groupId>
     <artifactId>aspectjrt</artifactId>
     <version>1.5.4</version>
     <scope>runtime</scope>
  </dependency><dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-orm</artifactId>
   <version>2.5.6</version>
  </dependency><dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-webmvc</artifactId>
   <version>2.5.6</version>
  </dependency><dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-context-support</artifactId>
   <version>2.5.6</version>
  </dependency><dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-jdbc</artifactId>
   <version>2.5.6</version>
  </dependency><dependency>
   <groupId>org.springframework.security</groupId>
   <artifactId>spring-security-core</artifactId>
   <version>2.0.4</version>
   <exclusions>
    <exclusion>
     <groupId>org.springframework</groupId>
     <artifactId>spring-aop</artifactId>
    </exclusion><exclusion>
     <groupId>org.springframework</groupId>
     <artifactId>spring-support</artifactId>
    </exclusion><exclusion>
     <groupId>org.springframework</groupId>
     <artifactId>spring-remoting</artifactId>
    </exclusion>
   </exclusions>
  </dependency><dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-aop</artifactId>
   <version>2.5.6</version>
  </dependency><dependency>
   <groupId>org.springframework.security</groupId>
   <artifactId>spring-security-acl</artifactId>
   <version>2.0.4</version>
  </dependency><dependency>
     <groupId>org.springframework.security</groupId>
     <artifactId>spring-security-core-tiger</artifactId>
     <version>2.0.4</version>
    </dependency><dependency>
     <groupId>org.springframework.security</groupId>
     <artifactId>spring-security-taglibs</artifactId>
     <version>2.0.5.RELEASE</version>
    </dependency><dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-beans</artifactId>
   <version>2.5.6</version>
   <type>jar</type>
   <scope>compile</scope>
  </dependency><dependency>
   <groupId>velocity</groupId>
   <artifactId>velocity</artifactId>
   <version>1.4</version>
  </dependency><dependency>
   <groupId>org.hibernate</groupId>
   <artifactId>hibernate</artifactId>
   <version>3.2.6.ga</version>
   <type>jar</type>
   <scope>compile</scope>
  </dependency>
 </dependencies>

 <distributionManagement>
  <repository>
   <id>releases-local</id>
   <name>releases</name>
   <url>http://localhost:12120/nexus-webapp-1.7.1/content/repositories/releases/</url>
  </repository>
  <snapshotRepository>
   <id>snapshot-local</id>
   <name>snaps</name>
   <url>http://localhost:12120/nexus-webapp-1.7.1/content/repositories/snapshots/</url>
  </snapshotRepository>
 </distributionManagement>
</project>
EN

回答 1

Stack Overflow用户

发布于 2013-02-17 18:50:11

是的,m2eclipse是一个老版本,或者包含几个bug。

你好,你遇到了同样的问题,我已经纠结了20多个小时。m2eclipse插件在其属性中包含了J2SE 1.5编译器,即使您在pom.xml中指定了正确的编译器,它也经常会中断。

代码语言:javascript
复制
create your own command: 
1) right click on project
2) Run as 
3) Run as maven build (5-th one)
4) on configuration panel specify your goals (site / test / clean)
5) **on JRE panel specify your JRE 1.6**
6) save your command as e.g. "maven site JDK 6"
7) run everything using your customs commands ("maven site JDK 6"), not built in commands. 

以下是我的其他技巧1)使用您自己的maven,而不是在m2eclipse中构建,您可以在m2eclipse首选项中切换到它

2)将存储库位置从愚蠢的C:\Users\current_user-m2\repository更改为D:\repository或不带~或任何其他特殊字母的任何其他正常路径

3)在恐慌前,用自己的maven检查控制台中的所有内容。例如,我的命令如下

代码语言:javascript
复制
mvn site
mvn install 
mvn tomcat:redeploy 

在控制台上工作得很好,但在eclipse内部却失败了。这意味着m2eclipse参数是错误的,您应该设置自己的参数。

4)不要依赖上下文命令(右键单击- run as - maven test / site / build)在run as - maven内置菜单中创建自己的命令,选择正确的JRE版本(在我的例子中是1.7),并添加任何额外的参数。不要忘了给这个命令起个名字,比如:"maven tomcat:redeploy JDK7“-这将给你一个很好的机会运行你想要的任何东西,并且不会面临90%的m2eclipse问题和bug。

另外,我在maven 2和m2eclipse上挣扎了20多个小时。希望我的技巧对某些人有用。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3544595

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档