zoukankan      html  css  js  c++  java
  • Maven 插件

    maven-replacer-plugin

      字符串替换插件:打包时替换某个文件中的此字符串为彼字符串

    根据不同的环境使用不同的数据库IP

    <build>
            <finalName>struts2</finalName>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.3</version>
                    <configuration>
                        <useCache>true</useCache>
                    </configuration>
                    <executions>
                        <execution>
                            <id>prepare-war</id>
                            <phase>prepare-package</phase>
                            <goals>
                                <goal>exploded</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>com.google.code.maven-replacer-plugin</groupId>
                    <artifactId>replacer</artifactId>
                    <version>1.5.2</version>
                    <executions>
                        <execution>
                            <phase>prepare-package</phase>
                            <goals>
                                <goal>replace</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <basedir>${project.build.directory}</basedir>
                        <includes>${project.build.finalName}/WEB-INF/classes/configuration.properties</includes>
                        <replacements>
                            <replacement>
                                <token>${database.name.dev}</token>
                                <value>${database.name.test}</value>
                            </replacement>
                        </replacements>
                    </configuration>
                </plugin>
            </plugins>
        </build>
        <profiles>
            <profile>
                <id>DATABASE_DEV</id>
                <activation>
                    <activeByDefault>true</activeByDefault>
                </activation>
                <properties>
                    <database.name.dev>USER_DEV</database.name.dev>
                    <database.name.test>USER_DEV</database.name.test>
                </properties>
            </profile>
            <profile>
                <id>DATABASE_TEST</id>
                <activation>
                    <activeByDefault>true</activeByDefault>
                </activation>
                <properties>
                    <database.name.dev>USER_DEV</database.name.dev>
                    <database.name.test>USER_TEST</database.name.test>
                </properties>
            </profile>
        </profiles>
    </build>

    打包时包含此文件不包含彼文件

    profile的作用是设置环境变量

      

    查看Plugin所包含的goals

      https://www.cnblogs.com/yitouniu/p/7573885.html

  • 相关阅读:
    css实现并列效果
    去除inline-block之间的间距
    鼠标点击<input>输入域后出现有颜色的边框
    消除a标签点击后产生的虚线框
    超过既定行数时,用省略号代替的方法
    常用按钮样式
    常用颜色
    通过Gulp流方式处理流程
    IntelliJ IDEA 10 配置 Tomcat7
    chrome浏览器调试线上文件映射本地文件
  • 原文地址:https://www.cnblogs.com/BINGJJFLY/p/8473279.html
Copyright © 2011-2022 走看看