mavan多平台打包

maven多平台打包

1.定义多个平台的profile,例如:

<profiles>
        <profile>
            
            <id>devid>
            <properties>
                <war.name.tag>devwar.name.tag>
            properties>
            <build>
                <resources>
                    <resource>
                        <directory>src/main/resources/Configration/devdirectory>
                    resource>
                resources>
            build>
            <activation>
                <activeByDefault>trueactiveByDefault>
            activation>
        profile>
        <profile>
            
            <id>testid>
            <properties>
                <war.name.tag>testwar.name.tag>
            properties>
            <build>
                <resources>
                    <resource>
                        <directory>src/main/resources/Configration/testdirectory>
                    resource>
                resources>
            build>
        profile>
        <profile>
            
            <id>prodid>
            <properties>
                <war.name.tag>prodwar.name.tag>
            properties>
            <build>
                <resources>
                    <resource>
                        <directory>src/main/resources/Configration/proddirectory>
                    resource>
                resources>
            build>
        profile>
    profiles>

2.把不同平台的配置变量不一样的放置在Configration目录下面的对应目录中如:

mavan多平台打包_第1张图片

3.在build的标签放置resources标签,加入resource处理:

    <resources>
        <resource>
            <directory>src/main/resourcesdirectory>
            <filtering>truefiltering>
            <excludes>
                <exclude>**/Configration/**exclude>
            excludes>
        resource>
    resources>

4.在idea的右边maven视图中,选择不同的平台打包:

mavan多平台打包_第2张图片

5.在idea的右边maven视图中,打开Lifecycle节点双击package进行打包:

mavan多平台打包_第3张图片

6.为了区分打包结完成后的不同平台,可以不同平台的包用不同的名,在build节点中加入一个finalName:

    ${name}-${war.name.tag}-${version}

你可能感兴趣的:(javaEE,maven,多环境打包-平台打包)