[超级前台]sprinbboot maven superdesk-app 记录

不是很明白, 为什么 superdesk-app 是这个mvn package -Dmaven.test=skip, 实际上也可以直接在pom文件中声明跳过测试
Maven编译插件及打包插件以及跳过测试插件, 参考:https://deepmind.t-salon.cc/article/3010

mvn package
mvn package -Dmaven.test=skip

superdesk-app-transfer , 参考https://deepmind.t-salon.cc/article/3009

mvn clean package -Dmaven.test.skip=true
[env][已经修正为这个了]
mvn clean package -Dmaven.test.skip=true -P prod

是因为有 maven-surefire-plugin 这个插件吗

[INFO] Building superdesk-app-transfer-old2new 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ superdesk-app-transfer-old2new ---
[INFO] Deleting /mnt1t/JAVA_HOME/superdesk-app-transfer/superdesk-app-transfer-old2new/target
[INFO] 
[INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ superdesk-app-transfer-old2new ---
[INFO] Using 'utf-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ superdesk-app-transfer-old2new ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 44 source files to /mnt1t/JAVA_HOME/superdesk-app-transfer/superdesk-app-transfer-old2new/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:3.0.1:testResources (default-testResources) @ superdesk-app-transfer-old2new ---
[INFO] Not copying test resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ superdesk-app-transfer-old2new ---
[INFO] Not compiling test sources
[INFO] 
[INFO] --- maven-surefire-plugin:2.21.0:test (default-test) @ superdesk-app-transfer-old2new ---
[INFO] Tests are skipped.
[INFO] 
[INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ superdesk-app-transfer-old2new ---
[INFO] Building jar: /mnt1t/JAVA_HOME/superdesk-app-transfer/superdesk-app-transfer-old2new/target/superdesk-app-transfer-old2new.jar
[INFO] ------------------------------------------------------------------------

打包单个

 mvn clean package -pl superdesk-libs-mybatis --also-make -Dmaven.test.skip=true

清理target

mvn clean

发布

mvn clean deploy -P snapshot -DskipTests=true
mvn clean deploy -P release -DskipTests=true
<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${compiler.jdk.version}</source>
                    <target>${compiler.jdk.version}</target>
                    <encoding>${output.encoding}</encoding>
                </configuration>
            </plugin>

            <!-- 打包时打不打源代码上去 -->
            <!--<plugin>-->
                <!--<groupId>org.apache.maven.plugins</groupId>-->
                <!--<artifactId>maven-source-plugin</artifactId>-->
                <!--<version>2.4</version>-->
                <!--<executions>-->
                    <!--<execution>-->
                        <!--<id>attach-sources</id>-->
                        <!--<phase>verify</phase>-->
                        <!--<goals>-->
                            <!--<goal>jar-no-fork</goal>-->
                        <!--</goals>-->
                    <!--</execution>-->
                <!--</executions>-->
            <!--</plugin>-->

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <configuration>
                    <skip>false</skip>
                </configuration>
            </plugin>
        </plugins>
    </build>

分析

mvn dependency:analyze
mvn dependency:analyze >> /mnt1t/superdesk-app-dependency-analyz.log

生成

mvn -Dverbose dependency:tree
mvn -Dverbose dependency:tree >> /mnt1t/superdesk-app-dependency-tree.log

加env 参数打包

[关于打包]
修改文件 01 pom.xml

添加 profiles 配置节

<project>

    ...
    
    <profiles>
        <profile>
            <!-- 本地开发环境 -->
            <id>dev</id>
            <properties>
                <profiles.active>dev</profiles.active>
            </properties>
            <!--默认启用的是dev环境配置-->
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
        </profile>
        <profile>
            <!-- 测试环境 -->
            <id>test</id>
            <properties>
                <profiles.active>test</profiles.active>
            </properties>
        </profile>
        <profile>
            <!-- UAT环境 -->
            <id>uat</id>
            <properties>
                <profiles.active>uat</profiles.active>
            </properties>
        </profile>
        <profile>
            <!-- 生产环境 -->
            <id>prod</id>
            <properties>
                <profiles.active>prod</profiles.active>
            </properties>
        </profile>
    </profiles>
</project>
修改文件 02 resources/application.properties

# 从原来的写死
spring.profiles.active=dev

# 改成读变量
spring.profiles.active=@profiles.active@
package 打包命令

# 从原来的这样
mvn clean package -Dmaven.test.skip=true

# 指定 profile id 为 prod 
mvn clean package -Dmaven.test.skip=true -P prod
[关于运行]
服务器运行 就不用再指定是读哪个了
java -Xms512m -Xmx1024m -jar superdesk-app-transfer-canal-instance-supercloud.jar
开发机运行

在Run Dashboard 添加

方法1 此方法为 maven 指定参数

Active profiles dev

设置 为 pom.xml 上 profiles profile id

方法2 此方法为覆写 springboot 参数

Override parameters

  • name

spring.profiles.active dev

(application-prod.properties) => prod
(application-test.properties) => test
(application-uat.properties) => uat
(application-dev.properties) => dev

请先后发表评论
  • 最新评论
  • 总共0条评论