MAVEN configuration-Create Web projects with MAVEN support for Tomcat directory deployment

Source: Internet
Author: User
Tags tomcat
MAVEN configuration-Create Web projects with MAVEN support for Tomcat directory deployment

First, create a MAVEN Web project operation steps:

1. Create a new dynamic Web Project.



2, set the Java source code directory for Scr/main/java, keep and Maven source code directory one to.



3. Set the Web content directory to Src/main/webapp. Also in order to maintain and Maven directory one to.



4. After the creation is complete, right-click on the project selection maven->enable Dependency Management, using maven to manage jar dependencies.



5. Set the POM and set the package type to war.



6. Add Maven dependencies to the Java EE Module dependencies.



7. Set the compilation path for Java code. The compilation path is set to Webapp/web-inf/classes to support directory deployment.



8. Set the compiler version.





Second, create a new Tomcat run server. Do not select the deployed project during the new process, and when you are finished, double-click the server to add it in the configuration to make the directory deployment. However, the jar package below Lib is not yet under Webapp/web-inf/lib. The default is to the/target/ecop_m2-1.0.1-snapshot/web-inf/lib directory.

Third, let Maven package, a copy of the jar to Webapp/web-inf/lib.

1, double hit open pom.xml file, switch to Pom.xml card. Add Maven dependency plug-ins and set up a copy of the jar to the Web at the time of packaging, so Tomcat can find the project jar when it starts.



The code is as follows:

<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/src/main/webapp/WEB-INF/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins> (2010-06-15 15:45:03) reprinted

Category: Maven

First, create a MAVEN Web project operation steps:

1. Create a new dynamic Web Project.



2, set the Java source code directory for Scr/main/java, keep and Maven source code directory one to.



3. Set the Web content directory to Src/main/webapp. Also in order to maintain and Maven directory one to.



4. After the creation is complete, right-click on the project selection maven->enable Dependency Management, using maven to manage jar dependencies.



5. Set the POM and set the package type to war.



6. Add Maven dependencies to the Java EE Module dependencies.



7. Set the compilation path for Java code. The compilation path is set to Webapp/web-inf/classes to support directory deployment.



8. Set the compiler version.





Second, create a new Tomcat run server. Do not select the deployed project during the new process, and when you are finished, double-click the server to add it in the configuration to make the directory deployment. However, the jar package below Lib is not yet under Webapp/web-inf/lib. The default is to the/target/ecop_m2-1.0.1-snapshot/web-inf/lib directory.

Third, let Maven package, a copy of the jar to Webapp/web-inf/lib.

1, double hit open pom.xml file, switch to Pom.xml card. Add Maven dependency plug-ins and set up a copy of the jar to the Web at the time of packaging, so Tomcat can find the project jar when it starts.



The code is as follows:

<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/src/main/webapp/WEB-INF/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.