I have a war dependency:
<dependency>
<groupId>my.package</groupId>
<artifactId>myservices</artifactId>
<version>0.3</version>
<type>war</type>
</dependency>
Now, this exists in my local repository, and the class exists at WEB-INF/classes/my/package/myservices
. When I go to use myservices
, however, I get package my.package
does not exist. Intelli-J knows to change myservices
into my.package.myservices
, but trying to import
seems to not work at all.
Is there something special I need to do with this war dependency?
It worked great with classes originating from external libraries which I could add as dependencies. However, it failed with classes originating from the Hippo CMS Site module because it was compiled into a . war archive which Maven can't handle as a dependency.
The Maven WAR plugin is responsible for collecting and compiling all the dependencies, classes, and resources of the web application into a web application archive. There are some defined goals in the Maven WAR plugin: war: This is the default goal that is invoked during the packaging phase of the project.
There are two types of dependencies in Maven: direct and transitive. Direct dependencies are the ones that we explicitly include in the project.
It just doesn't work that way. war files are not supposed to be put on the classpath, but deployed to application servers (or servlet containers) that can deal with their special structure.
Of course you can probably find a custom classloader somewhere that can deal with java war files, but it's just not the way to do it.
Keep your code in a jar, include the jar in your war and in this application. But don't use a war as a dependency, unless you are building an EAR file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With