• java源代码编译war包


    Java编译工具

    • maven编译

    • ant编译

    • gradle编译

    安装maven

    wget https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
    tar xf apache-maven-3.6.3-bin.tar.gz -C /usr/local
    ll /usr/local/apache-maven-3.6.3/
    ln -s /usr/local/apache-maven-3.6.3/ /usr/local/maven
    ll /usr/local/maven/
    vim /etc/profile
    #文件结尾添加两行
    export M2_HOME=/usr/local/maven
    export PATH=${M2_HOME}/bin:$PATH
    
    source /etc/profile
    mvn -v
    • 更改maven源
    vim  /usr/local/maven/conf/settings.xml
    #将所有内容复制到<mirrors>之间
    <mirror> 
        <id>nexus-aliyun</id>  
        <mirrorOf>central</mirrorOf>    
        <name>Nexus aliyun</name>  
        <url>http://maven.aliyun.com/nexus/content/groups/public</url>  
    </mirror>

    maven编译war包

    源码包地址:https://pan.baidu.com/s/1AsI2dErbhDNt2qXQjjVbew

    提取码:fwva

    tar xf SpringBootWeb.tar.gz -C /opt/
    • 编译war包

    注:执行maven需要在特定的目录

    cd /opt/SpringBootWeb
    mvn package
    #执行完毕!
    [INFO] Packaging webapp
    [INFO] Assembling webapp [SpringBootWeb] in [/opt/SpringBootWeb/target/SpringBootWeb]
    [INFO] Processing war project
    [INFO] Copying webapp resources [/opt/SpringBootWeb/src/main/webapp]
    [INFO] Webapp assembled in [327 msecs]
    [INFO] Building war: /opt/SpringBootWeb/target/SpringBootWeb.war
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time:  01:00 min
    [INFO] Finished at: 2020-03-24T23:32:36+08:00
    [INFO] ------------------------------------------------------------------------
    
    [root@web01 /opt/SpringBootWeb]# ls
    pom.xml  src  target
    [root@web01 /opt/SpringBootWeb]# cd target/
    [root@web01 /opt/SpringBootWeb/target]#  ls
    classes  generated-sources  maven-archiver  maven-status  SpringBootWeb  SpringBootWeb.war <--war包
    [root@web01 /opt/SpringBootWeb/target]# mv SpringBootWeb.war /app/tomcat/webapps/ROOT.war
    #将war包放如tomcat的webapps/下面重启tomcat
  • 相关阅读:
    项目报错二
    项目报错一
    OCP-1Z0-051-V9.02-21题
    Windows API——OpenClipboard——剪切板
    如果在CEdit中实现Ctrl+V、Ctrl+C、Ctrl+X的功能
    OCP-1Z0-051-V9.02-18题
    OCP-1Z0-051-V9.02-17题
    OCP-1Z0-051-V9.02-15题
    OCP-1Z0-051-V9.02-14题
    OCP-1Z0-051-V9.02-12题
  • 原文地址:https://www.cnblogs.com/Mercury-linux/p/12559514.html
Copyright © 2020-2023  润新知