Why does the Maven Assembly Plugin not include my project files in the dependency bank?

I use the maven assembly plug in to package my project with all its dependencies, so I can run a simple java -jar myproject.jar and be able to run the project. However, when I launched the can, they told me that

Error: Could not find or load main class com.project.ServerStart 

Then I unzipped the .jar file and found that the assembly does not include my project files, which is ridiculous!
When I pack a project, I get this warning

 [WARNING] Cannot include project artifact: Amjar:amjar:pom:0.2; it doesn't have an associated file or directory. 

This is my config plugin

 <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>2.4</version> <configuration> <finalName>amjar-${project.version}</finalName> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> <archive> <manifest> <addClasspath>true</addClasspath> <mainClass>com.project.ServerStart</mainClass> </manifest> </archive> </configuration> <executions> <execution> <id>assemble-all</id> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> </plugins> </build> 

What am I doing wrong?

+6
source share
1 answer

From the warning you indicated in your question:

 [WARNING] Cannot include project artifact: Amjar:amjar:pom:0.2; it doesn't have an associated 

I assume that you have packaging in your pom.xml installed on pom .

This is normal if your module simply packs a set of dependencies or resource files, however, if you also want Maven to create a jar containing the classes in your module, you need to install packaging in a jar .

+8
source

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


All Articles