zoukankan      html  css  js  c++  java
  • 8.Eclipse中创建Maven Web项目

    

    第一步:

    创建maven webproject

    注意以下一步:

    第二步:

    继承parent

    改动pom.xml文件例如以下

    <projectxmlns="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>cn.toto.maven</groupId>

     <artifactId>web</artifactId>

     <packaging>war</packaging>

     <name>web Maven Webapp</name>

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

     

      <parent> 

       <groupId>cn.toto.maven</groupId>

        <artifactId>Parent</artifactId>

        <version>0.0.1-RELEASE</version>

       <relativePath>../Parent/pom.xml</relativePath> 

     </parent>

     

     <dependencies>

       <dependency>

         <groupId>junit</groupId>

          <artifactId>junit</artifactId>

       </dependency>

       <dependency>

         <groupId>cn.toto.maven</groupId>

         <artifactId>MakeFriends</artifactId>

       </dependency>

     </dependencies>

     

    </project>

     

    第三步:

    建立測试jsp

    <%@ page language="java"contentType="text/html; charset=UTF-8"

        pageEncoding="UTF-8"%>

    <%@ pageimport="cn.toto.maven.MakeFriends.*"%>

    <%

        MakeFriendsmakeFriends=new MakeFriends();

       out.println(makeFriends.makeFriends("wanglipeng"));

    %>

     

    第四步:

    自己主动部署到tomcat以下(web项目下的pom.xml)

    <build>

       <finalName>web</finalName>

       <plugins>

             <plugin>

                 <groupId>org.codehaus.cargo</groupId>

                 <artifactId>cargo-maven2-plugin</artifactId>

                 <version>1.2.3</version>

                 <configuration>

                     <container>

                         <containerId>tomcat7x</containerId>

                         <!以下是Tomcat在电脑上的位置à

                         <home>D:/Program Files/ApacheSoftware Foundation/Tomcat 5.0</home>

                     </container>

                     <configuration>

                         <type>existing</type>

                         <home>D:/Program Files/ApacheSoftware Foundation/Tomcat 5.0</home>

                     </configuration>

                 </configuration>

                 <executions> 

                     <execution> 

                         <id>cargo-run</id> 

                         <phase>install</phase> 

                         <goals> 

                             <goal>run</goal> 

                         </goals> 

                     </execution> 

                 </executions>

             </plugin>

         </plugins>

      </build>

     

    第五步:

    模块聚合

    改动parent.pom

     

    Web模块中的完整的pox.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>

      <artifactId>web</artifactId>

      <packaging>war</packaging>

     

      <name>web Maven Webapp</name>

     

       <parent> 

            <groupId>cn.toto.maven</groupId>

            <artifactId>Parent</artifactId>

            <version>0.0.1-SNAPSHOT</version>

            <relativePath>../Parent/pom.xml</relativePath> 

      </parent>

      <dependencies>

      <dependency>

          <groupId>junit</groupId>

          <artifactId>junit</artifactId>

        </dependency>

        <dependency>

          <groupId>cn.toto.maven</groupId>

          <artifactId>MakeFriends</artifactId>

        </dependency>

    </dependencies>

      <build>

        <finalName>web</finalName>

        <plugins>

              <plugin>

                  <groupId>org.codehaus.cargo</groupId>

                  <artifactId>cargo-maven2-plugin</artifactId>

                 <version>1.2.3</version>

                 <configuration>

                     <container>

                         <containerId>tomcat7x</containerId>

                          <!以下是Tomcat在电脑上的位置à

                         <home>D:/Program Files/Apache Software Foundation/Tomcat 5.0</home>

                     </container>

                     <configuration>

                         <type>existing</type>

                         <home>D:/Program Files/Apache Software Foundation/Tomcat 5.0</home>

                     </configuration>

                 </configuration>

                 <executions> 

                      <execution> 

                          <id>cargo-run</id> 

                          <phase>install</phase> 

                          <goals> 

                              <goal>run</goal> 

                          </goals> 

                      </execution> 

                  </executions>

              </plugin>

          </plugins>

      </build>

     

    </project>

    注意:

     

    Parent中的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/xsd/maven-4.0.0.xsd">

      <modelVersion>4.0.0</modelVersion>

     

      <groupId>cn.toto.maven</groupId>

      <artifactId>Parent</artifactId>

      <version>0.0.1-SNAPSHOT</version>

      <packaging>pom</packaging>

     

      <name>Parent</name>

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

    <modules>

        <module>../Hello</module> 

        <module>../HelloFriend</module>   

        <module>../MakeFriends</module>

        <module>../web</module>

    </modules>

      <properties>

        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

      </properties>

     

      <dependencyManagement>

      <dependencies>

        <dependency>

          <groupId>junit</groupId>

          <artifactId>junit</artifactId>

          <version>4.9</version>

          <scope>test</scope>

        </dependency>

        <dependency>

          <groupId>cn.toto.maven</groupId>

          <artifactId>HelloFriend</artifactId>

          <version>0.0.1-SNAPSHOT</version>

          <scope>compile</scope>

        </dependency>

        <dependency>

               <groupId>cn.toto.maven</groupId>

               <artifactId>Hello</artifactId>

               <version>0.0.1-SNAPSHOT</version>

               <scope>compile</scope>

           </dependency>

           <dependency>

               <groupId>cn.toto.maven</groupId>

               <artifactId>MakeFriends</artifactId>

               <version>0.0.1-SNAPSHOT</version>

               <scope>compile</scope>

           </dependency>

      </dependencies>

    </dependencyManagement>

    <distributionManagement>

        <repository>

            <id>releases</id>

            <name>Internal Releases</name>

            <url>http://localhost:8080/nexus-2.1.2/content/repositories/releases/</url>

        </repository>

        <snapshotRepository>

            <id>snapshots</id>

            <name>Internal Snapshots</name>

            <url>http://localhost:8080/nexus-2.1.2/content/repositories/snapshots/</url>

        </snapshotRepository>

      </distributionManagement>

     

    </project>

     

     

  • 相关阅读:
    5.颜色空间转换
    Linux下的解压命令
    4.图像模糊/图像平滑
    insightface作者提供数据训练解读
    MXNetError: [05:53:50] src/operator/nn/./cudnn/cudnn_convolution-inl.h:287
    python中import cv2遇到的错误及安装方法
    docker 安装 mxnet
    95. Unique Binary Search Trees II
    236. Lowest Common Ancestor of a Binary Tree
    124. Binary Tree Maximum Path Sum
  • 原文地址:https://www.cnblogs.com/hrhguanli/p/4083755.html
Copyright © 2011-2022 走看看