The idea Community Edition has a lot less functionality than a premium version, including support for Web servers such as Tomcat. Most of the online Idea Web App release tutorials are based on paid editions, and the Community edition doesn't have the tools to run or publish Web apps. Fortunately, it is proven that the MAVEN plugin can be used to achieve the tomcat7-maven-plugin and release of Web applications.
Preparatory work
Check that the following components have been installed and configured:
Tomcat needs to be configured to run as a tomcat user, and if you do not follow the steps to configure Tomcat first:
New User:
sudo useradd tomcat-p Tomcat
To modify the owner of the Tomcat installation directory:
chown -R tomcat:tomcat/opt/apache-tomcat
Modify the user profile for Tomcat:/opt/apache-tomcat/conf/tomcat-users.xml
<tomcat-users> <rolerolename= "Tomcat"/> <rolerolename= "Manager"/> <rolerolename= "Manager-gui"/> <rolerolename= "Manager-script" /> <rolerolename= "Admin-gui"/> <Userusername= "Tomcat"Password= "Tomcat"Roles= "Tomcat,manager, Manager-gui,manager-script,admin-gui" /></tomcat-users>
Know that the Manager page will open normally: Http://localhost:8080/manager
Configure the idea so that you can run the tune Web App configuration project run configuration directly in idea
Create a new MAVEN configuration
Edit Run Configuration
Name: From a name
Working directory: Select your project path
Command line: Fill in tomcat7:run (if you are installing TOMCAT7)
Edit the project's Pom.xml file
Add the Tomcat7-maven-plugin plugin to the Pom.xml
<Build> <pluginmanagement> <plugin> <groupId>Org.apache.tomcat.maven</groupId> <Artifactid>Tomcat7-maven-plugin</Artifactid> <version>2.2</version> <Configuration> <Port>8181</Port> <Server>Tomcat7</Server> <Path>/testing</Path> </Configuration> </plugin> </Plugins> </pluginmanagement> </Build>
Port: 8181
Path to the Web:/testing
Run the project
Click the green triangle directly or press the shortcut key SHIFT+F10
Enter the address in the browser: http://localhost:8181/testing/
You'll be able to access your Web project.
Publish your web App with maven
Re-edit the project's Pom.xml file
<Build> <pluginmanagement> <plugin> <groupId>Org.apache.tomcat.maven</groupId> <Artifactid>Tomcat7-maven-plugin</Artifactid> <version>2.2</version> <Configuration> <Port>8181</Port> <Server>Tomcat7</Server> <Path>/testing</Path> <URL>Http://localhost:8080/testing</URL> <username>Tomcat</username> <Password>Tomcat</Password> <Update>True</Update> </Configuration> </plugin> </Plugins> </pluginmanagement> </Build>
Increase:
URL: The URL of the Web project you want to publish
Username/password: The username and password here should be the same as the user name password that runs Tomcat
Update: Whether updates
modifying Maven's Settings.xml
When you add a server node:
<Servers> <Server> <ID>Tomcat</ID> <username>Tomcat</username> <Password>Tomcat</Password> </Server></Servers>
Publish a web App with the MAVEN command
Go to the root of the project you want to publish, and then execute the following command:
Install Package tomcat7:redeploy-dmaven.test.skip=true
The-dmaven.test.skip=true command is designed to skip unit tests if your project does not need to be skipped and can be removed.
If you get the following information, congratulations, your Web app was published successfully:
Ok! You can find the website you just published in the WebApps directory of Tomcat:Testing.war
Idea Community Edition mode in Tomcat 7 and publish Web Apps