美文网首页
maven命令deploy使用

maven命令deploy使用

作者: 小强不可爱 | 来源:发表于2019-01-08 07:31 被阅读0次

    deploy的用法:将maven的web项目部署到远程服务器。
    准备工作:
    1.远程服务器tomcat
    tomcat需要的配置信息:tomcat-users.xml

    <role rolename="admin-gui"/>
    <role rolename="admin-script"/>
    <role rolename="manager-gui"/>
    <role rolename="manager-script"/>
    <role rolename="manager-jmx"/>
    <role rolename="manager-status"/>
    <user username="admin" password="admin" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-script,admin-gui"/>
    

    2.maven
    maven需要的配置工作:settings.xml

    <servers>
        <server>
            <!--对应pom.xml中的server-->
            <id>tomcat7</id>
            <!--此处的用户名和密码需要和上面tomcat中的用户名和密码一致-->
            <username>admin</username>
            <password>admin</password>
        </server>
    </servers>
    
    

    3.项目
    项目中需要订单配置信息:pom.xml

    <build>
            <plugins>
                <!-- 配置Tomcat插件 -->
                <plugin>
                    <groupId>org.apache.tomcat.maven</groupId>
                    <artifactId>tomcat7-maven-plugin</artifactId>
                    <version>2.2</version>
                    <configuration>
                        <path>/</path>
                        <port>9090</port>
                        <!-- 远程tomcat地址加上manager/text -->
                        <url>http://172.30.4.241:8080/manager/text</url>
                         <!-- 此处的名字必须和settings.xml中配置的ID一致 -->
                        <server>tomcat7</server>
                        <update>true</update>
                    </configuration>
                </plugin>
            </plugins>
            <finalName>${project.artifactId}</finalName>
    </build>
    

    4.deploy使用

        a.直接使用idea中maven插件中的tomcat7:deploy进行部署
        b.使用dos命令进行部署mvn  tomcat7:deploy
    

    5.遇到的一些问题
    a.代码开发使用的时UTF-8编码,里面有中文,网上说时windows系统默认编码时GBK,导致出现这种warning,


    warning.png

    解决方法:在pom.xml中指定编码UTF-8

    <properties>    
          <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>  
          <maven.compiler.encoding>UTF-8</maven.compiler.encoding>
    </properties>
    

    b.编码的时候jdk版本不一样,没有指定泛型的类型

    source 1.5 中不支持 diamond 运算符
    [ERROR]   (请使用 -source 7 或更高版本以启用 diamond 运算符)
    
    List<Items> itemList = new ArrayList<>();//导致上面那出现的问题
    //添加上泛型类型就可以解决
    //List<Items> itemList = new ArrayList<Items>();
    

    相关文章

      网友评论

          本文标题:maven命令deploy使用

          本文链接:https://www.haomeiwen.com/subject/vhwmrqtx.html