Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
536 views
in Technique[技术] by (71.8m points)

tomcat - IntelliJ IDEA: Maven, project compilation and deployment

Can someone explain me IntelliJ IDEA's workflow of compilation, deployment and packaging with binded maven project ?

I've encountered some misunderstanding when I'm starting tomcat server via IDEA's debug mode. For example I have one artifact - war archive. As I understand when I'm running debug mode - IDEA recompiles and updates changed code into war-archive.

But what happens with packaged maven artifact ? Does IntelliJ updates it ? Or I have to set 'Buld maven before startup' option to be sure that changed code will be uploaded to environment ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Intelli J doesn't use maven to build the project it uses its own build process. It uses the pom file as a description of the project.

This means a couple of things, if you want to build an artifact such as a war file when running in tomcat then all you have to do is tell IntelliJ to build the war in the Run/Debug Configurations dialog. IntelliJ will automatically build any artifacts you specify under the deployment tab of your run/debug configuration. So if you specify the exploded war it will build the exploded war, if you specify the regular war it will build the regular war.

Occasionally people need to run custom plugins or build targets in which case you can configure IntelliJ to run the custom maven goals.

You can also tell intellIJ to run the maven package goal rather than build the artifact. IntelliJ will deploy whatever is under the target directory to tomcat.

The important take away is IntellIJ is using two separate build systems. You need to tell each build system what to do. And you need to tell IntelliJ which build system to use for what. IntelliJ will by default use it's own build system once a project has been imported, unless you tell it to use maven for something.

While IntelliJ will build the artifact you specify in the pom file it won't do things like deploy them your artifact repository (local or other wise) unless you click on the deploy target in the Maven tools window.

Also if you change your pom file and don't have auto re-import enabled those changes won't be reflected in your project until you click the force re-import option from the maven tools window.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...