eclipse web項目轉maven項目


ps:好久沒寫博客了,工作了人就懶了,加油加油,up,up

 

 

1 eclipse web項目目錄

/web app

   src

       com.xx.xx

       *.properties

       *.xml

    WebRoot

        ​WEB-INF

    ​    ​    ​classes

    ​    ​    ​lib

    ​    ​    ​*.xml

    ​    ​index.jsp

2 轉為maven項目,添加pom.xml

1) 創建maven web項目,把eclipse web文件拷貝到新的項目中

2) 通過在項目上右鍵->轉為maven項目,填寫信息自動創建pom.xml

3)直接在項目中創建pom.xml文件

原始pom.xml文件:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <groupId>com.syx</groupId>

  <artifactId>web</artifactId>

  <packaging>war</packaging>

  <version>0.0.1-SNAPSHOT</version>

  <name>web Maven Webapp</name>

  <url>http://maven.apache.org</url>

  <dependencies>

  </dependencies>

  <build>

    <finalName>web</finalName>

  </build>

</project>

3 配置class輸出目錄和項目jar包依賴

  1)把項目的src目錄配置/WebRoot/WEB-INF/classes目錄下

  2)把項目的lib目錄jar添加到classpath

4 添加pom jetty插件和配置

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <groupId>Maven Web</groupId>

  <artifactId>Maven Web</artifactId>

  <version>0.0.1-SNAPSHOT</version>

  <build>

    <plugins>

      <plugin>

        <groupId>org.mortbay.jetty</groupId>

        <artifactId>maven-jetty-plugin</artifactId>

        <version>6.1.15</version> 

        <configuration>

          <contextPath>/</contextPath>

          <webAppSourceDirectory>WebRoot</webAppSourceDirectory>  

          <scanIntervalSeconds>2</scanIntervalSeconds>

          <stopKey>foo</stopKey>

          <stopPort>9090</stopPort>

          <connectors>

            <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">

              <port>8080</port>

              <maxIdleTime>60000</maxIdleTime>

            </connector>

          </connectors>

        </configuration>

      </plugin>

      <plugin>

        <artifactId>maven-clean-plugin</artifactId>

        <configuration>

          <filesets>

            <fileset>

              <directory>WebRoot/WEB-INF</directory>

              <includes><include>classes</include></includes>

              <followSymlinks>false</followSymlinks>

            </fileset>

          </filesets>

        </configuration>

      </plugin>

    </plugins>

  </build>

</project>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM