IntelliJ IDEA Ultimate JBoss + Maven configuration
Hello everyone,
in our business unit we are evaluating the possibility of switching from Eclipse to IntelliJ IDEA Ultimate for our development process. We work with 2 main kind of projects:
- Spring Boot web services
- Web application running on JBoss and using Spring Web Flow, JSF and Primefaces as main technologies
In both cases we use maven for dependency management and packaging.
The first case works fine in IntelliJ IDEA since we can run our web services as standalone applications thanks to Spring Boot, but we are having some problems with the second project:
The project produces 2 artifacts to be deployed: a war and an ear, both generated by maven. The first problem is that the only way I found to be able to deploy a maven generated artifact was to use an "external source" in the deployment tab of the server (the artifacts aren't correctly recognized by IntelliJ in the artifact section) and add the 2 artifacts from the target folder. In the "Before launch" option I specified to launch the maven build in order to be sure to have the updated artifacts before launching the server.
This is fine for starting the server and debugging, but the main problem is having the changes to the code reflected in the running server without the need to restart it (our application takes quite long to startup, so hot code replace is a critical feature for us). By what I understand, the only possible options for this configuration are "redeploy" or "restart server", which are both quite time consuming.
Is there a way to have both hot code replace and using maven generated artifacts in IntelliJ? At my current level of knowledge it seems that this is possible only by using the "manual" artifact generation provided by IntelliJ, but in this way we would need to rework something that is already done in maven (we should specify how to build the ear and the war mentioned earlier), and I am not even sure that in this way we can have resulting artifacts that are 100% like the maven generated ones. Is this correct? Or is there a way to achieve what we need that I missed?
I hope I exposed our problem in a quite clear way and that someone can help me clarifying this doubt, thank you in advance.
请先登录再写评论。
Hi Gabriel. Yes, you are quite right in your assumptions:
>Is there a way to have both hot code replace and using maven generated artifacts in IntelliJ? At my current level of knowledge it seems that this is possible only by using the "manual" artifact generation provided by IntelliJ,
For the IDE to be able to update changed resources and hot deploy changed classes the deployed artifacts must be produced by the IDE and must be of an exploded (un-archived) type, including all nested artifacts that needed to be updated.
Other resources that you deploy to a server would be recognized by the IDE as external source.
>I am not even sure that in this way we can have resulting artifacts that are 100% like the maven generated ones.
Could you please clarify, have you tried using IDE-produced artifacts? Usually, IDE is able to migrate the artifacts build logic from Maven configuration for the IDE's own artifact builds. What specific Maven configuration does not work for them?
>Or is there a way to achieve what we need that I missed?
For the deployed artifacts, IDE uses the artifact output directory as the application deployment directory, so I would assume that any files which are updated there, should be recognized by the application server as updated too, provided that the application server is configured for the detection of the hot reload and the artifact of an exploded (un-archived) type.
Hi Andrey, first of all thank you for your time answering my question. I guess the part I am missing is this:
I tried using IDE-produced artifacts, but there were two main problems: only the war was recognized, while the ear isn't listed in the artifact section and, trying to deploy the IDE-generated war along with the ear deployed as "external source" I was getting various errors at the server startup. Is there any setting or procedure to tell IntelliJ to read the artifacts build logic from Maven?
>only the war was recognized, while the ear isn't listed in the artifact section
Please install the Java EE: Enterprise Java Beans (EJB) plugin if you do not have it installed. Does it help?
>Is there any setting or procedure to tell IntelliJ to read the artifacts build logic from Maven?
There are not specific to this options. Though the plugins for the related technologies must be enabled for the IDE to recognize corresponding Maven configurations.
I installed the Java EE: Enterprise Java Beans (EJB) plugin and re-imported the projects: now the ear is recognized, I tried to deploy the IDE-produced artifacts, the ear seems to be deployed correctly, while I get an error for the war:
I think it may be related to this maven configuration in the war-plugin section of the pom:
This should be a module provided by the AS, but it looks like it is not correctly loaded.
You can compare the generated by IDE exploded war and the war generated by Maven to se if there are differences.
May be related: IDEA-79492 Custom web.xml location ignored when generating artifact
But last time I checked - it worked for me.