I have a multi-module project in my IntelliJ environment. I want to create and deploy war for only one module in apache tomcat. (IntelliJ comes with default installation of tomcat.)
I have worked almost four years with Eclipse and started with IntelliJ like three days back. Just the way we right click on the project in eclipse and say export as war and it directly deploys in my app server, can I do same / similar in IntelliJ?
Any help will be helpful.
Thanks
PS : may be stupid to ask but would mac / windows make difference?
on the main toolbar or press Ctrl+Alt+S to open the Settings/Preferences dialog, and choose the Deployment page (you can access the same page by choosing Tools | Deployment | Configuration from the main menu).
File | Project Structure and click Artifacts. Click Add + and 'Web Application:war exploded' then it will pop-up your project and select it and hit OK and then go and do Build > Build Artifact. Good luck.
To create war file, you need to use jar tool of JDK. You need to use -c switch of jar, to create the war file. Go inside the project directory of your project (outside the WEB-INF), then write the following command: jar -cvf projectname.
It took me a while to realise that you can't build a war file with intellij community edition, at least I could not do it looking at answers from this thread.
My approach was to download and activate "Maven Helper" plugin directly from the IDE ie. File->settings->Plugins.
Then, select your pom.xml in the project viewer and in the "Run" tab, you will be able to choose Run new Maven Goal. There simply add the command line "clean install". Your war file (if you selected war in your pom.xml file) will be located under the folder "target" in your project main folder.
This absolutely works!
First:
Wow, I was reading and trying the answers provided and i couldnt believe why no one mentions the root of the issue which is "NOT MENTIONING THE WAY YOU WANT YOUR OUTPUT TO BE" which is war
so lets first tell intellij what we want by adding bellow tag to your pom.xml
<packaging>war</packaging>
where to paste? anywhere inside <project>
tag
Now lets talk about the method
You can install "Maven Helper" plugin as it will help beginners nicely, but if your intelij has a good handshake with maven, it will automatically or manually refresh your project and add the war capability to your maven settings ( the panel you see at the right hand side of the editor that mentions Maven) there you click on Plugins and you should see now you have war (org.apache.maven.plugins:maven-war-plugin:xxx)
as you click on the + you see many options, war:war and war:exploded are your friends to do what you like
<!-- Package as an executable jar/war -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
Use clean to dust off the previous mess, use war:war to create .war file, and for manifest war:exploded will do, if these didnt help for manifest, use the
File | Project Structure and click Artifacts. Click Add + and 'Web Application:war exploded' then it will pop-up your project and select it and hit OK and then go and do Build > Build Artifact.
Good luck.
Ctrl+Shift+Alt+S
and click Artifacts.You should see the artifact <project >/out/artifacts/Web Application_war.war
GL
Source
IntelliJ has different process to build war:
Goto -> Files -> Project Structure -> Artifacts
In artifacts tab, you will see a small + button on top right corner. Click it and fill up the right panel data such as name and output directory.
Make sure to create the Manifest file. Keep default location for Manifest file.
After building manifest, click apply->Ok.
Now you can go to Build-> Build Artifact.
Your .war file will be ready in the output folder you specified above.
you can use maven build to create war file. Go to right maven -> Lifecycle -> double click package. You can see your war generated default directory i.e Target
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