The project will treat the maven dependency as a folder instead of a jar file, and at runtime gives a ClassNotFoundError

In my maven project, I have this dependency, which is my own project, which is installed on my local maven (via cmd mvn install):

    <dependency>
        <groupId>com.myproject</groupId>
        <artifactId>api-core</artifactId>
        <version>1.0.0</version>
    </dependency>

However, when I start the tomcat server, I will get a ClassDefNotFoundError for the classes inside this project.

I tried to add the jar to the deployment assembly through the project properties, however, when I add this jar file, it is taken as a folder and will always be placed in the deployment path "WEB-INF / lib / core.api.1.0.0.jar", which then it is a folder inside lib, so tomcat cannot find the jar file. I also noticed that in the web deployment assembly, Maven Dependencies are deployed to WEB-INF / lib. Apparently my own jar file is not considered Maven Dependencies when it is deployed. When I additionally study Maven's dependencies on Eclipse, the jar file is packaged internally as a "main" folder, and it is not considered a jar file. Therefore, at runtime, the web application cannot find the jar file and gives me a complaint.

, Eclipse , Eclipse - "", , , , , , . , maven jar, tomcat !

, , , , ?

+4
1

, : -, Maven Resolve dependencies from workspace projects: , Eclipse Maven.

+1

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


All Articles