How to add module compile output to web-inf/classes in stead of web-inf/lib?
I'm using maven to set up a war project in
IntelliJand run in it
GlassFish. The war project depends on several other modules. When I run the project in debug mode, hot deploying codechanges of the changes results in
NoClassDefFoundexceptions. I found out that
IntelliJtries to redeploy the module jar but
GlassFishkeeps a lock on it so it fails. All the classes in that module are now unavailable, causing these
NoClassDefFoundexceptions.
IntelliJgenerates the artifacts this way: the dependent modules are all added as jar dependencies as if they were external dependencies:

Now, when I remove the jar dependencies,
IntelliJtells me it found some missing dependencies and proposes a fix to add the missing dependencies.
Fixing those dependencies will add the module compile output to the
WEB-INF\classesfolder.

Once deployed,
IntelliJhas no problem anymore hot-deploying changed classes to GlassFish since there's no jar to keep a lock on.
Problem
Every time I make a change to any
pom.xml,
IntelliJrefreshes the artifacts automatically, which is fine: I definitely want to see those changes appear in the artifact. However, all modules are added as
jardependencies again.
Question
How can I make sure that IntelliJ adds the compile output of project modules to
WEB-INF\classesand not to
WEB-INF\lib? (or: is there another way to avoid those
NoClassDefFounderrors?
I found this question but it has two problems:
- There are many module dependencies so if possible I'd like to avoid specifying them all one by one in the unpack goal
-
IntelliJ
seems to ignore this. When I add that configuration and while it works perfectly in a maven commandline build,IntelliJ
still refuses to add the module compile output to theWEB-INF\classes
dir
I found a bugreport that asks about the same thing but for me it's hard to believe there's no way to solve this problem. Other webapp developers using
IntelliJmust have this same issue, making it difficult to hot-deploy code changes, unless I did something wrong in my
pomconfiguration.
请先登录再写评论。
I have a similar problem. Intellij compiles the classes inside target/classes, which is ok because I use maven. But I need the same classes inside WEB-INF/classes too.
Eclipse seems to be able to do this automatically, but for Intellij we use a workaround. You could use the plugin "maven-antrun-plugin" with copy function to refresh automatically the classes inside WEB-INF before launch.
Thank you for the information. Please vote and follow this related request in our tracker: https://youtrack.jetbrains.com/issue/IDEA-88392