Build failed due to missing libraries

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project spring-intergation: Compilation failure: Compilation failure: [ERROR] \spring-intergation\src\main\java\uk\co\dd\spring\domain\User.java:[3,24] package javax.persistence does not exist [ERROR] \spring-intergation\src\main\java\uk\co\dd\spring\domain\User.java:[4,24] package javax.persistence does not exist [ERROR] \spring-intergation\src\main\java\uk\co\dd\spring\domain\User.java:[5,24] package javax.persistence does not exist [ERROR] \spring-intergation\src\main\java\uk\co\dd\spring\domain\User.java:[6,24] package javax.persistence does not exist [ERROR] \spring-intergation\src\main\java\uk\co\dd\spring\domain\User.java:[7,24] package javax.persistence does not exist [ERROR] \spring-intergation\src\main\java\uk\co\dd\spring\domain\User.java:[9,1] cannot find symbol 

But I added all the libraries in my eclipse by right-clicking on the project and adding external banks.

When I try to start mvn compilation, I get these errors along with a lot of other jars.

 <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"> <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <executions> <execution> <goals> <goal>java</goal> </goals> </execution> </executions> <configuration> <mainClass>uk.co.dd.spring.App</mainClass> </configuration> </plugin> </plugins> </build> <modelVersion>4.0.0</modelVersion> <groupId>uk.co.dd.spring</groupId> <artifactId>spring-intergation</artifactId> <packaging>jar</packaging> <version>1.0-SNAPSHOT</version> <name>spring-intergation</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring</artifactId> <version>2.5.5</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> </project> 

Do I have to do anything with POM.xml

+7
source share
2 answers

Add this to your addiction

 <dependency> <groupId>javax.persistence</groupId> <artifactId>persistence-api</artifactId> <version>1.0</version> </dependency> 
+20
source

The whole point of maven is that you describe all the dependencies of your project in pom.xml , rather than adding them as banners to your development environment.

If you have dependencies configured in pom.xml , you can easily generate an Eclipse project with the appropriate dependencies by running mvn eclipse:eclipse or add them to an existing project with m2eclipse .

+2
source

All Articles