Two previous articles:
Create a new MAVEN Framework Web project
And
Change original project to MAVEN framework
After that, we've got Maven's project.
So
How did the MAVEN project start?
If we press the previous startup method directly in the MyEclipse, it is not possible. (More on the next article: Start the MAVEN project in MyEclipse)
However, the MAVEN project can generate a local war package to manually move to Tomcat, or it can be automatically published to local, remote Tomcat.
So we're going to try both of these ways:
Generate a war package, run it manually
Right-click on the project, run as-----> Maven Install will generate the war package locally
Find the relevant directory:
Copy this package to the WebApp path of our natively installed Tomcat:
Start Tomcat:
After the start, one thing to note:
The access page is the same path as the published project, even if the web directory is set to Ipfilterm
But here to use:
Ipfilterm-0.0.1-snapshot
otherwise 404
Problems you may encounter:
The MAVEN-generated war package ran an error under Tomcat
Automatically publish to local, remote tomcat
Modify the next Tomcat configuration file first
Tomcat-users.xml in the---installation directory
Tomcat7.0\conf\tomcat-users.xml
[Java]View Plaincopy
- <tomcat-users>
- <role rolename="Manager-gui"/>
- <role rolename="manager"/>
- <role rolename="Manager-script"/>
- <user username="Tomcat" password="Tomcat" roles="Manager-gui,manager,manager-script"/>
- </tomcat-users>
If you already have the relevant user information, you do not have to add, but the permissions should be added
<role rolename= "Manager-gui"/>
<role rolename= "Manager"/>
<role rolename= "Manager-script"/>
Manager-gui,manager,manager-script
After the Tomcat configuration is successful, it can be Localhost:8080\manager
The Tomcat admin interface is logged in as follows:
Modify the configuration file under Maven
Settings.xml in the---installation directory
Maven\conf\settings.xml
Find servers modified as follows, or add on:
[Java]View Plaincopy
- <servers>
- <server>
- <id>mytomcat7</id>
- <username>tomcat</username>
- <password>tomcat</password>
- </server>
- </servers>
Add Tomcat7-maven-plugin
Externally configured, now configure the Pom in Web engineering to add Tomcat7-maven-plugin
[Java]View Plaincopy
- <build>
- <finalName>peopleDataShow</finalName>
- <plugins>
- <plugin>
- <groupId>org.apache.tomcat.maven</groupId>
- <artifactId>tomcat7-maven-plugin</artifactId>
- <version>2.2-snapshot</version>
- <configuration>
- <path>/${project.build.finalName}</path>
- <server>mytomcat7</server>
- <!--here is the local tomcat, if the remote server can be changed to the corresponding address for automatic deployment--
- <url>http://localhost:8080/manager/text</url>
- </configuration>
- </plugin>
- </plugins>
- </build>
That is, adding Tomcat's plugin to the build tag.
<finalName> name of the project that corresponds to itself
Add plug-in configuration-----Do not add the report 400 403 error
[Java]View Plaincopy
- <repositories>
- <repository>
- <id>people.apache.snapshots</id>
- <url>http://repository.apache.org/content/groups/snapshots-group/</url>
- <releases>
- <enabled>false</enabled>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </repository>
- </repositories>
- <pluginRepositories>
- <pluginRepository>
- <id>apache.snapshots</id>
- <name>apache snapshots</name>
- <url>
- http://repository.apache.org/content/groups/snapshots-group/
- </url>
- <releases>
- <enabled>false</enabled>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </pluginRepository>
- </pluginRepositories>
Start TOMCAT7, perform maven build
Configure goals
Successful deployment after clicking Run
This item is already visible in Tomcat's admin interface or folder.
Run directly in the MyEclipse
We start directly through the MyEclipse, sometimes error, but this situation can be solved.
The cause of the error
By default, MAVEN's resources Tomcat is not recognized, and once deployed directly using the previous method, there is no configuration file in Classpath.
I just want to use MAVEN to manage the jar package, as far as the development of the deployment to the Web server for debugging, I still want to let MyEclipse help me to complete, how to configure, in order to let the deployment past, the configuration file appears in the Web-inf/classes directory?
We're going to check to see if there are files in resources under the directory that was added to Tomcat.
Inspection found, and sure enough.
Then we're going to set the release path to the resources folder.
To the project right-click Properties--->myeclipse--->deployment Assembly set the resource folder output path to the same as Src/main/java
OK, so we can start the project and debug directly in the MyEclipse.
Start without error, and page access can also be used.
At this time the path of the project is the path of the web/root we set up, ipfilterm, the difference between playing the war package and putting it into Tomcat run.
3 |
< role rolename = "manager-gui" /> |
4 |
< role rolename = "manager" /> |
5 |
< role rolename = "manager-script" /> |
6 |
< user username = "tomcat" password = "tomcat" roles = "manager-gui,manager,manager-script" /> |
[Java]View Plaincopy
- <tomcat-users>
- <role rolename="Manager-gui"/>
- <role rolename="manager"/>
- <role rolename="Manager-script"/>
- <user username="Tomcat" password="Tomcat" roles="Manager-gui,manager,manager-script"/>
- </tomcat-users>
MyEclipse using the Summary--maven project how to start a run publish to Tomcat [go]