Idea intellij maven can't do

I have a maven project. Maven is building complete SUCCESS. But I can not do this project.

[INFO] CREATE SUCCESS

The project contains one module. An idea cannot see the addiction.

Error:(3, 38) java: D:\Dropbox\Programming\java\spring\springBook\src\main\java\ch14\validator\ContactTestValidator.java:3: package org.springframework.stereotype does not exist 

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/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>springBook</groupId> <artifactId>springBook</artifactId> <version>1.0-SNAPSHOT</version> <!-- Shared version number properties --> <properties> <org.springframework.version>3.2.3.RELEASE</org.springframework.version> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <!--   --> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.5.6</version> </dependency> <dependency> <!--Spring Data JPA   -   --> <!--API    --> <!--ch14 validator--> <groupId>joda-time</groupId> <artifactId>joda-time</artifactId> <version>2.0</version> </dependency> <dependency> <!--ch14 validator--> <!--API  JSR-303--> <groupId>javax.validation</groupId> <artifactId>validation-api</artifactId> <version>1.0.0.GA</version> </dependency> <dependency> <!--ch14 validator--> <!--API,    JSR-303 - BeanValidation--> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> <version>4.0.2.GA</version> </dependency> <dependency> <!-- . (@Type...)--> <groupId>org.hibernate</groupId> <artifactId>hibernate-annotations</artifactId> <version>3.5.6-Final</version> </dependency> <dependency> <groupId>cglib</groupId> <artifactId>cglib</artifactId> <version>2.2.2</version> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjtools</artifactId> <version>1.6.2</version> </dependency> <!--Spring framework--> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${org.springframework.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>${org.springframework.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${org.springframework.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> <version>${org.springframework.version}</version> </dependency> </dependencies> <build> <finalName>springBook</finalName> </build> </project> 

could you help me? Sorry, I cannot add screenshots. There are screenshots: http://screencast.com/t/iNaWO9gy http://screencast.com/t/iBGTyMpgH

Project settings - Libraries - empty;

reimport did not help;

+8
source share
8 answers

Follow these steps:

  1. Find your pom.xml in your files
  2. Right click on it -> Maven -> Import
  3. Wait for the project to load: D
  4. Press ctrl + alt + shift + s (the Projects window will open.)
  5. Go to the libraries and see if they are empty (they shouldn't)
  6. If they publish your full pom.xml, please so that I can see the problem
  7. If the problem persists, go to File β†’ Invalidate Caches / Reboot
  8. Go to Maven and re-import all Maven projects
+27
source

The Maven -> Reimport should force Intellij to reload all dependencies. Alternatively, as noted in the comments, you can click the Reimport All Maven Projects button Reimport All Maven Projects view.

+5
source

In my case, I had my own apache-maven-3.5.2 folder, and the wrong setup created my problem. Perhaps this is your business:

In a hurry, I installed a local repository in C: /my/folder/apache-maven-3.5.2/settings.xml, but it should be a folder, so Maven did not allow me to download dependencies. Then I changed the default value (in the picture) and it worked.

enter image description here

+3
source

Open the module dependencies (press F12 on the module), go to Modules -> Dependencies and make sure the maven import is part of this.

+1
source

Try importing the project from sources if this answer did not help you.

+1
source

The following worked for me.

  • Removed maven dependency on my local repository
  • mvn clean install downloads the dependency again.
  • File -> Invalid Cache / Restart
  • I still saw a compilation error
  • on my mac, I press the + enter option, intellij asked me to add a jar to the classpath
  • build β†’ make project
+1
source

I ran into the same problem and the problem was small. I changed the location of the settings.xml file from maven, and Intellij collected the default value from C: \ users \ .m2 \ settings.xml

So, specify your maven settings.xml in the correct file, as shown below: File β†’ Settings β†’ assembly, execution, deployment β†’ Maven then in the right window redefine the β€œUser settings file” in the settings.xml file, where you have it on the local disk .

If you installed maven in a non-default location, then you can find this file in: \ Apache-Maven-3.2.3 \ conf \ settings.xml

+1
source

Right click on pom.xml and click Add as Maven Project

+1
source

All Articles