So, I created the Spring Maven Project, the Dao Project, which works great. All code is in the right place, all unit tests run, and I can do a clean mvn installation. I see in the target directory that there is a collector, and everything in it looks great. I can also confirm that when I check my local .m2 / repository, the last jar that I just built appears.
Here is a small segment of this pom.xml:
<modelVersion>4.0.0</modelVersion> <groupId>com.tom.myproject</groupId> <artifactId>myproject-dao</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>My Project DAO</name>
Now I am creating a new Spring Maven web project for my user interface and this pom.xml starts as:
<modelVersion>4.0.0</modelVersion> <version>0.0.1-SNAPSHOT</version> <groupId>com.tom.myproject</groupId> <artifactId>myproject-ws</artifactId> <name>My Web Project</name> <packaging>war</packaging>
Also in this pom.xml file, one of the first dependencies I have is:
<dependency> <groupId>com.tom.myproject</groupId> <artifactId>myproject-dao</artifactId> <version>0.0.1-SNAPSHOT</version> <type>jar</type> <scope>compile</scope> </dependency>
In the eclipse, I see that when I try to access the classes from this tao jar, everything seems to be fine. When I compile the code here, everything works fine. And when I do "mvn clean install" to create this war, I see the target directory, and all the necessary classes and banks are included, obviously there are hibernation, logging and Spring classes that are in WEB -INF / lib.
Now this is the part in which the question arises ... Why does myproject-dao appear under WEB-INF / lib as WEB-INF / lib / myproject-dao-0.0.1-SNAPSHOT.jar, but appear as a directory and not a jar?
Of course, when I pull out other jars, these are just .jar files, not directories.
I have to add, when you look in the Eclipse project under the maven dependencies, the icon for all other jars shows them as files. The icon of my myproject-dao.jar uses the icon for the folder / directory, so a directory called "myproject-dao.jar" is created, not a file with archived contents in the jar file.
When I create a war file and deploy the war, the application says that it cannot find any of the classes in the myproject-dao.jar directory. I need to remove the FOLDER "myproject-dao.jar" from the WEB-INF / lib directory and manually copy the FILE file "myproject-dao.jar". Then I can clearly see the icon, which means that it is really a file.
This is probably a simple fix, so if you can help me, it will be great.
Answer:
I did not use maven-assembly-plugin. But I found out what the problem is.
Both my DAO project and the WEB project are in the same workspace, and the DAO project was opened, as a result, the maven dependency shown in Eclipse was a folder icon, not a jar icon. When I closed the DAO project and looked at the maven dependencies in the pom.xml file of the WEB project ... NOW it shows the icon as a jar, not a folder.
So, all I need to do is create a dao.jar file with maven, and when it succeeds, it will be done. Then I need to CLOSE the project in Eclipse. In my pom.xml file of the web project, the icon will now show this as a jar file, and when it is created, it will pull in jars.
I assume this is useful if you are working on several previous projects, you really have a chance to see what is in the jar file during the war.
In my case, I know that my dao.jar works, so I can build it and close the project, and then use this jar wherever I need it.