Maven does not find class

I have inherited a huge java maven project and cannot compile it.

mvn compile

Telling me that he cannot find the class, even if he is there, in the local repo.

Failed to execute goal org.codehaus.enunciate:maven-enunciate-plugin:1.25:assemble (default) on project VCWH_Core_QueryService: Execution default of goal org.codehaus.enunciate:maven-enunciate-plugin:1.25:assemble failed: A required class was missing while executing org.codehaus.enunciate:maven-enunciate-plugin:1.25:assemble: com/sun/mirror/apt/AnnotationProcessorFactory

Here is a pom.xml snippet that tells where to look:

 <dependency>
  <groupId>com.sun</groupId>
  <artifactId>tools</artifactId>
  <version>1.7</version>
 </dependency>

And, of course, tools-1.7.jar and tools-1.7.pom are located in the local repo in

\.m2\repository\com\sun\tools\1.7

And if I look in the jar with jar tf tools-1.7.jar I see a class

com/sun/mirror/apt/AnnotationProcessorFactory.class

I also blew out the sun folder in my local repo and did Clean & Build in NetBeans and watched the solar folder return to my local repo, so I know that the connection to the remote repo is good.

Why can't he find him?

+5
source share
5 answers

You need to add this to the maven-enunciate-plugin:

                        <dependencies>
                            <dependency>
                                <groupId>com.sun</groupId>
                                <artifactId>tools</artifactId>
                                <version>1.7</version>
                                <scope>system</scope>
                                <systemPath>C:\Program Files\Java\jdk1.7.0_79\lib\tools.jar</systemPath>
                                <optional>true</optional>
                            </dependency>
                        </dependencies>

:

<plugin>
                <groupId>org.codehaus.enunciate</groupId>
                <artifactId>maven-enunciate-plugin</artifactId>
                <version>1.25</version>
                <configuration>
                    <configFile>${basedir}/src/main/webapp/WEB-INF/enunciate.xml</configFile>
                    <compileDebug>false</compileDebug>
                    <addGWTSources>false</addGWTSources>
                    <addActionscriptSources>false</addActionscriptSources>
                </configuration>
                <dependencies>
                    <dependency>
                    <groupId>com.sun</groupId>
                    <artifactId>tools</artifactId>
                    <version>1.7</version>
                    <scope>system</scope>
                    <systemPath>C:\Program Files\Java\jdk1.7.0_79\lib\tools.jar</systemPath>
                    <optional>true</optional>
                    </dependency>
                </dependencies>

                <executions>
                    <execution>
                        <goals>
                            <goal>assemble</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

Java 7 8.

0

jar , . . .m2/repository/com/sun/mirror/apt/apt-mirror-api/0.1/apt-mirror-api-0.1.jar.

, , . , Nexus, , Maven . , pom, ​​ GAV.

+1

mvn clean compile -U mvn clean install -U

0

2 . .

mvn clean install.

eclipse, project clean. right click project->maven->update project.

0

, Maven (groupId, artifactId ). .

-

Maven. .

1:

  • : Maven >

  • : /

  • Ok

Maven .

, 2

2:

  • Maven, .m2 .

MS Windows

either
C: \ Documents and Settings \ .m2 C: \ Users \ .m2

On Mac / Linux

~ / .m2

-

Please note: in your OS, you may need to configure the OS to display hidden files.

  1. After removing the .m2 directory, restart Eclipse

  2. In your project, right-click: Maven> Update Project

This will solve your problem.

-1
source

Source: https://habr.com/ru/post/1615846/


All Articles