`
85977328
  • 浏览: 1869870 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

maven 之web项目的profile

 
阅读更多
有时候maven管理war项目,需要根据不同的环境,使用不同的配置文件。

pom.xml文件如下
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.chinaso</groupId>
    <artifactId>test</artifactId>
    <packaging>war</packaging>
    <version>1.0.0</version>
    <url>http://maven.apache.org</url>
    <properties>
        <!-- 
                     不加下面这一行会报错
        [WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
                     增加之后
        Using 'UTF-8' encoding to copy filtered resources.
       -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>

        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>1.4</version>
        </dependency>
        <dependency>
            <groupId>commons-pool</groupId>
            <artifactId>commons-pool</artifactId>
            <version>1.5.7</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>test</finalName>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <archive>
                        <addMavenDescriptor>false</addMavenDescriptor>
                    </archive>
                    <webResources>
                        <resource>  
                            <!-- 元配置文件的目录,相对于pom.xml文件的路径 -->
                            <directory>${app_config_path}</directory>  
                            <!-- 是否过滤文件,也就是是否启动auto-config的功能 -->
                            <filtering>false</filtering>  
                            <!-- 目标路径 -->
                            <targetPath>WEB-INF/conf</targetPath>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>dev</id>
            <properties>
                <app_config_path>src/main/conf/dev</app_config_path>
            </properties>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
        </profile>
        <profile>
            <id>test</id>
            <properties>
                <app_config_path>src/main/conf/test</app_config_path>
            </properties>
        </profile>
        <profile>
            <id>online</id>
            <properties>
                <app_config_path>src/main/conf/online</app_config_path>
            </properties>
        </profile>
    </profiles>
</project>


打包命令
mvn clean package -Dmaven.test.skip=true -Pdev

输出日志
[INFO] --- maven-war-plugin:2.1.1:war (default-war) @ test ---
[INFO] Packaging webapp
[INFO] Assembling webapp [test] in [E:\x\test\target\y]
[INFO] Processing war project
[INFO] Copying webapp webResources [E:\E:\x\test\target\ysrc/main/conf/dev] to [E:\x\test\target\y]
[INFO] Copying webapp resources [E:\x\test\target\y\src\main\webapp]
[INFO] Webapp assembled in [4776 msecs]
[INFO] Building war: E:\x\test\target\vertical-search.war
[WARNING] Warning: selected war files include a WEB-INF/web.xml which will be ignored
(webxml attribute is missing from war task, or ignoreWebxml attribute is specified as 'true')



参考文章
http://lishuaibt.iteye.com/blog/614783
分享到:
评论

相关推荐

    maven+spring+mybatis配置

    1.非web环境下spring如何与mybatis集成 2.maven如何打可以直接运行的jar包 3.maven如何用profile动态打包jdbc.properties 4.maven如何把mybatis的mapper.xml一起打包到jar中

    maven window下安装包

    第13章:使用Maven生成项目原型/13.1 Maven项目原型/13.1.4 命令行生成的web项目原型 第13章:使用Maven生成项目原型/13.2 编写自己的项目原型/13.2.1 自定义项目原型结构组成 第13章:使用Maven生成项目原型/13.2 ...

    Maven权威指南 很精典的学习教程,比ANT更好用

    一个简单的Maven项目 3.1. 简介 3.1.1. 下载本章的例子 3.2. 创建一个简单的项目 3.3. 构建一个简单的项目 3.4. 简单的项目对象模型 (Project Object Model) 3.5. 核心概念 3.5.1. Maven插件和目标 ...

    《Maven权威指南》[PDF]

    目前绝大多数用户都在使用Maven2)的风格,通过一个个生动实际的例子,循序渐进的阐释了Maven的用法和核心概念,这些例子从最简单的命令行程序,到Web应用,到多模块项目,直至多模块企业级项目。第二部分为Maven...

    nanogo:Maven项目构建工具

    用户可以通过NanoGo快速构建基于NanoFramework的Web项目和Scheduler项目. NanoGo还提供了自定义项目构建的方法, 通过编写yaml文件对项目进行定义与编排. 下载安装 前往 ...

    mvn-examples-1.0&Maven;权威指南中文版

    &lt;module&gt;ch05-simple-web &lt;module&gt;ch06-multi &lt;module&gt;ch07-multi-spring &lt;module&gt;ch08-optimize &lt;module&gt;ch09-pom &lt;module&gt;ch10-lifecycle &lt;module&gt;ch11-profile &lt;module&gt;ch12-assembly &lt;module&gt;ch13-...

    api-master:api-master是springMVC项目,基于maven多模块和dubbo的rpc方式整合使用

    项目基于maven的多profile环境配置,打包时需要选择(test/pro/dev)打包运行的环境。 **项目特点** - 友好的代码结构及注释,便于阅读及二次开发 。 - 前端页面采用jsp+freemaker,多视图解析处理,优先jsp。 - 采用...

    intellig-server:基于springboot的脚手架项目,继承了mybatis自动生成、maven多环境配置、log4j2多环境、assembly生成发布包

    intellig-server基于springboot的web...基于maven的profile支持多环境切换3.接入log4j2,支持多环境配置4.采用assembly打包插件,生成最终发布包5.使用vue前端5.新增linux启动脚本,可根据环境定制(20190824)6.接入netty

    nemo-utils:对 Nemo 项目有用的 Java 实用程序类和小型框架

    尼莫实用程序 该存储库由包含实用程序类和小型框架的项目组成,这些... 要将上述项目之一设置为 Maven2 依赖项,请将以下存储库添加到项目的pom.xml &lt; enabled&gt;true &lt; updatePolicy&gt;always &lt; checksumP

    dubbo、dubbox编译所需jar包

    maven-profile-2.0.9.jar maven-profile-2.0.jar maven-project-2.0.4.jar maven-project-2.0.5.jar maven-project-2.0.8.jar maven-project-2.0.9.jar maven-project-2.0.jar maven-reporting-api-2.0.9.jar maven-...

    springboot学习思维笔记.xmind

    web项目设置在Servlet的context parameter中 事件Application Event 自定义事件,集成ApplicationEvent 定义事件监听器,实现ApplicationListener 使用容器发布事件 Spring高级话题 Spring Aware ...

    FocusSNS JSP社交系统 v1.1.3

    使用 jetty-maven-plugin 插件作为 Web 开发环境 2.默认使用 MySql 数据库,并用最近的 MySql 脚本初始化数据库 3.优化项目依赖,目前只依赖 Maven 中央仓库,当然 Spring4Me 还是依赖的,你需要自己下载 Spring4Me ...

    Jetty中文手册

    Jetty and JEE6 Web Profile 配置参考 Jetty XML语法(Syntax)–Jetty IOC Configuration Jetty XML用法–Using and Combining Jetty Configurations 配置文件 jetty.xml–Server configuration jetty-web.xml–Web...

    client_chaining_algorithms

    从以下位置下载WebProfile,ZIP: ://tomee.apache.org/downloads.html 解压缩在IntelliJ IDEA中:注册“ TomEE Server”-&gt;本地: 按“修复”,选择“爆炸战争”作为神器设置页面: http://localhost:8081/ 设定...

    wMessages:使用登录帐户从 web.whatsapp.com 获取 WhatsApp 消息

    为 Firefox 设置一个名为“myProfile”的配置文件,并将 web.whatsapp.com 的登录会话保存到同一个 使用以下 mvn 命令通过命令行运行项目: mvn clean test 如果您想加载较早的消息,请使用 mvn 命令: mvn clean ...

    checklistbank:GBIF Checklist Bank

    这是一个多模块项目,包含从api到持久层到Web服务客户端的所有ChecklistBank模块。 集成测试是各个模块的一部分,尤其是在Web服务客户端和mybatis模块中。 Maven个人资料 要运行所有测试,您需要定义以下属性的...

    CXF创建webservice服务端.doc

    1. 支持 Web Services 标准:CXF 支持多种 Web Services 标准,包含 SOAP、Basic Profile、WS-Addressing、WS-Policy、WS-ReliableMessaging 和 WS-Security。 2. Frontends:CXF 支持多种“Frontend”编程模型,...

    TendereteOnline:使用Hibernate + Spring + Bootstrap + jQuery开发的在线商店的Java EE Web应用程序

    这是类Unix系统的“〜/ .bash_profile”文件的摘录。 适应您的环境。 J2SE 导出JAVA_HOME = / opt / jdk1.7.0_05 对于Mac OS X,使用: 导出JAVA_HOME = / Library / Java / JavaVirtualMachines / 1.7.0.jdk / ...

Global site tag (gtag.js) - Google Analytics