eclipse web項目轉maven項目

ps:很久沒寫博客了,工做了人就懶了,加油加油,up,upweb

 

 

1 eclipse web項目目錄

/web appapache

   srcapp

       com.xx.xxeclipse

       *.propertiesjsp

       *.xmlmaven

    WebRootui

        ​WEB-INFurl

    ​    ​    ​classesspa

    ​    ​    ​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>

相關文章
相關標籤/搜索