• 折腾spring boot 应用


     

    开发环境

    安装配置java环境

    配置maven环境,修改镜像地址

            <mirror>
                <id>aliyunmaven</id>
                <mirrorOf>*</mirrorOf>
                <name>阿里云公共仓库</name>
                <url>https://maven.aliyun.com/repository/public</url>
            </mirror>
            <!-- 中央仓库1 -->
            <mirror>
                <id>repo1</id>
                <mirrorOf>central</mirrorOf>
                <name>Human Readable Name for this Mirror.</name>
                <url>http://repo1.maven.org/maven2/</url>
            </mirror>
        
            <!-- 中央仓库2 -->
            <mirror>
                <id>repo2</id>
                <mirrorOf>central</mirrorOf>
                <name>Human Readable Name for this Mirror.</name>
                <url>http://repo2.maven.org/maven2/</url>
            </mirror>

    配置vscode

    参数配置

    Spring Boot Extension Pack,Java Extension Pack,Maven for Java修改vscode配置文件:
     
       "explorer.confirmDelete": false,
        "editor.suggestSelection": "first",
        "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
        "java.errors.incompleteClasspath.severity": "ignore",
        "editor.minimap.enabled": false,
        "window.zoomLevel": 0,
        "workbench.editor.enablePreview": false,
        "workbench.editor.enablePreviewFromQuickOpen": false,
        "editor.renderIndentGuides": false,
        "editor.highlightActiveIndentGuide": false,
        "java.home": "C:\Program Files\AdoptOpenJDK\jdk-11.0.4.11-hotspot",        
        "editor.fontSize": 15,
        "editor.lineHeight": 30,
        "maven.executable.path": "E:\StaticSoft\apache-maven-3.6.1\bin\mvn.cmd",       
        "java.configuration.maven.userSettings": "E:\StaticSoft\apache-maven-3.6.1\conf\settings.xml",       
        "maven.terminal.customEnv": [
            {
                "environmentVariable": "JAVA_HOME",       
                "value": "C:\Program Files\AdoptOpenJDK\jdk-11.0.4.11-hotspot"       
            }
        ],
        "terminal.integrated.shell.linux": "/bin/bash",
        "java.jdt.ls.vmargs": "-noverify -Xmx1G -XX:+UseG1GC -XX:+UseStringDeduplication"

     创建项目

    Ctrl+Shift+p 

    配置项目

    在srcmain esources中创建application.yml文件:

    server:
      port: 8080
      servlet:
       context-path: /demo

    配置项目启动类:

    @SpringBootApplication
    public class DemoApplication extends SpringBootServletInitializer {
        public static void main(String[] args) {
            SpringApplication.run(DemoApplication.class, args);
        }
        @Override
        protected SpringApplicationBuilder configure(SpringApplicationBuilder builder){
            return builder.sources(DemoApplication.class);
        }
    }

    打包

    在项目根目录执行mvn命令:

    E:StaticSoftapache-maven-3.6.1inmvn war:war

    将target下的war包改为demo.war

    服务器环境

    centos7安装docker,使用tomcat镜像8.5,运行,并将webapps映射出来

    docker run -d -p 60800:8080 --name tomcat -v=/mnt/raid1/docker/tomcat:/usr/local/tomcat/webapps tomcat:latest 

    将demo.war上传到/mnt/raid1/docker/tomcat中

    开放60800端口

    firewall-cmd --zone=public --add-port=60800/tcp --permanent
    firewall-cmd --reload

    访问地址:http://172.16.88.88:60800/demo/demosign

  • 相关阅读:
    Java 二维数组
    JAVA——运算符
    JAVA——类与对象
    Eclipse无法自动编译出class文件 转
    引导入单用户模式
    安装sql server遇到问题解决方法
    数据结构和算法分析学习
    开源软件
    POP3、SMTP、IMAP和Exchange都是个什么玩意?
    邮件相关名词 MUA, MTA
  • 原文地址:https://www.cnblogs.com/Celebrator/p/11376289.html
Copyright © 2020-2023  润新知