Java spring-boot build

maven packaging

mvn clean install -U -DskipTests

Execute the jar file

 java -jar skr_java-0.0.1-SNAPSHOT.jar

change service port

The application.properties
configuration file format can be modified to the yaml file format application.yaml

server.port=****

pom.xml multiple sets of development environment configuration

    <profiles>
        <!--指定开发环境-->
        <profile>
            <id>dev</id>
            <properties>
                <spring.profiles.active>dev</spring.profiles.active>
            </properties>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
        </profile>
        <!--多套环境 测试环境-->
        <profile>
            <id>test</id>
            <properties>
                <spring.profiles.active>test</spring.profiles.active>
            </properties>
        </profile>
    </profiles>

server start service

Port specified priority
shell command > application-x.properties > application.properties
1. Create shell script xxx.sh

# 指定最大最小内存及方法大小
# 脚本最好加上使环境变量生效,防止因环境变量问题导致服务启动失败
nohup java -Xms256m -Xm512m -XX:PermSize=64m -XX:MaxPermSize=128m -server -Dserver.port=8080 -jar xxxxx.jar 'xxxxx' --spring.profiles.active=dev >>./test_info_8080.log 2>&1 &

# 相关操作命令
ps -ef | grep xxxxx # 查询已经存在的xxxxx进程,进程号为6666
kill -9 6666 # 杀进程
sh xxx.sh # 执行启动命令
tail -f test_info_8080.log # 查看日志

gi

Guess you like

Origin blog.csdn.net/weixin_43587784/article/details/129144844