Why can't maven compiler resolve class from depedency?
Eclipse can build this project, the dependency jar is in the local repository, the compiler lists the jar. I'm using Eclipse Helios with Maven Integration For Eclipse (0.10.2);
And yet it fails because the compiler can't resolve PropertiesEditor from spring-beans-2.5.6.jar.
Here is the full report from the build
http://wellingtonpeoplescentre.org.nz/geek/maven-wigout.txt
and here is my POM.
<?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>
<artif开发者_开发技巧actId>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>
Yep, m2eclipse is an old one or contains several bugs.
Hello, you've faced the same problem I've been struggling for more than 20 hours. m2eclipse plugin has J2SE 1.5 compiler somewhere inside his properties, even if you specify the correct one in pom.xml it breaks quite often.
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.
HERE ARE MY OTHER TIPS 1) user your own maven, not build in m2eclipse, you can switch to it in m2eclipse preferences
2) change repository location from the foolish one C:\Users\current_user-m2\repository to D:\repository or to any other normal path without ~ or any other special liters
3) check everything in console with your own maven before panic. For example my commands like
mvn site
mvn install
mvn tomcat:redeploy
work EXCELLENT from console, but fail from inside eclipse. That means m2eclipse parameters are wrong and you should set your own parameters.
4) don't rely on context commands (right click - run as - maven test / site / build) create your own command in run as - maven build - in menu choose the correct version of JRE (1.7 in my case) and add any additional parameters don't forget to give this command your name like: "maven tomcat:redeploy JDK 7" - that will give you a good chance to run whatever you want and don't face 90% of m2eclipse problems and bugs.
P.S. I was struggling maven 2 and m2eclipse for more than 20 hours. Hope my tips will be userful for some one.
精彩评论