zoukankan      html  css  js  c++  java
  • springboot项目maven配置多环境

    maven配置多环境

    filtering:开启过滤,用指定的参数替换directory下的文件中的参数(eg. ${name})

    directory:指定资源文件的位置。
    mvn resources:resources :对资源做出处理,先于compile阶段。

     <build>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>
                <!--     配置默认跳过单元测试 结束-->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <configuration>
                        <skip>true</skip>
                    </configuration>
                </plugin>
    
                <!-- 编译 -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                        <encoding>${project.build.sourceEncoding}</encoding>
                        <compilerArguments>
                            <extdirs>${project.basedir}/lib</extdirs>
                        </compilerArguments>
                    </configuration>
                </plugin>
    
                
                <!--  配置多环境-->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>2.5</version>
                    <executions>
                        <execution>
                            <id>copy-resources</id>
                            <phase>compile</phase>
                            <goals>
                                <goal>copy-resources</goal>
                            </goals>
                            <configuration>
                                <overwrite>true</overwrite>
                                <outputDirectory>${project.build.outputDirectory}</outputDirectory>
                                <resources>
                                    <resource>
                                        <directory>src/main/resources/profiles/${active.profile}</directory>
                                        <filtering>false</filtering>
                                    </resource>
                                </resources>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
    
    
            </plugins>
            <finalName>DXBChannel</finalName>
    
            <!--        配置资源目录-->
            <resources>
                <resource>
                    <directory>src/main/resources</directory>
                    <excludes>
                        <exclude>profiles/*</exclude>
                    </excludes>
                    <!--<filtering>true</filtering>-->
                </resource>
                <resource>
                    <directory>src/main/resources</directory>
                    <includes>
                        <include>**/*.xml</include>
                    </includes>
                </resource>
            </resources>
        </build>
    
    
        <!--配置环境的profile-->
        <profiles>
            <!--dev默认激活,使用idea Spring Boot 配置启动工程,需要dev的配置-->
            <profile>
                <id>dev</id>
                <properties>
                    <active.profile>dev</active.profile>
                </properties>
                <activation>
                    <activeByDefault>true</activeByDefault>
                </activation>
            </profile>
            <profile>
                <id>test</id>
                <properties>
                    <active.profile>test</active.profile>
                </properties>
            </profile>
            <profile>
                <id>prod</id>
                <properties>
                    <active.profile>prod</active.profile>
                </properties>
            </profile>
        </profiles>
    </project>
  • 相关阅读:
    汉字转拼音
    多数组求笛卡尔积
    curl post参数,接口接收不到数据问题
    判断IMEI或MEID是否合法
    javascript 可控速度的上下拉菜单
    去掉android点击事件产生的半透明蓝色背景
    go.js是什么
    jQuery效果——动画
    jQuery选择器
    vue全局组件局部组件的使用
  • 原文地址:https://www.cnblogs.com/zhangshiwen/p/12184797.html
Copyright © 2011-2022 走看看