`

maven profile整合spring profile方式

阅读更多

1.POM中build-resources-resource添加资源指向

<build>
        <finalName>lx-service</finalName>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
...
</build>

 

2.POM中build-plugins-plugin添加war打包插件配置

<!-- war打包插件, 设定war包名称不带版本号 -->
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <configuration>
        <webResources>
            <resource>
                <filtering>true</filtering>
                <directory>src/main/resources/profile</directory>
                <targetPath>WEB-INF</targetPath>
                <includes>
                    <include>**/web.xml</include>
                </includes>
            </resource>
        </webResources>
    </configuration>
</plugin>

 3.src/main/resources/profile下添加web.xml,其中可以使用maven profiles定义的变量

<!-- 设定Spring Context的默认Profile -->
<context-param>
    <param-name>spring.profiles.default</param-name>
    <param-value>${mvn.spring.profile}</param-value>
</context-param>

 4.打包的时候会自动修改该值。

5.注意,本地开发的时候仍然读取src/main/webapp/WEB-INF/web.xml中的spring.profiles,

 

分享到:
评论

相关推荐

    maven+spring+mybatis配置

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

    springboot实现maven打包加载不同环境的方式二

    当前案例中包含一整套的代码和word文档,非常适合新手... 主要是通过maven打包加载不同环境的properties文件 然后将对于的属性绑定到指定的实体对象中;然后通过调用接口可以看到加载不同环境控制台打印的内容是不一样的

    Maven管理SpringBoot Profile详解

    主要介绍了Maven管理SpringBoot Profile详解,具有一定参考价值,需要的朋友可以了解下。

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

    Maven权威指南 Authors Tim O'Brien (Sonatype, Inc.) , John Casey (Sonatype, Inc.) , Brian Fox (Sonatype, Inc.) , Bruce Snyder () , Jason Van Zyl (Sonatype, Inc.) , Juven Xu () Abstract Maven权威指南...

    spring-boot-reference.pdf

    13.2.3. Using the Spring Boot Maven Plugin 13.3. Gradle 13.4. Ant 13.5. Starters 14. Structuring Your Code 14.1. Using the “default” Package 14.2. Locating the Main Application Class 15. ...

    force-maven-plugin:部署到Salesforce的Maven Mojo原型

    尝试一下: 克隆回购mvn install-这将把force-maven-plugin安装到您的本地.m2存储库中在〜/ .m2 / settings.xml中创建Maven配置文件 &lt;profile&gt; &lt;id&gt;my-project&lt;/id&gt; &lt;properties&gt; &lt;sf&gt;xxx&lt;/sf&gt; &lt;sf&gt;xxx&lt;/sf&gt; ...

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

    &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-properties &lt;module&gt;ch15-sitegen &lt;module&gt;ch17-...

    Mastering.Spring.Cloud

    Native profile support Building a server-side application Building a client-side application Adding a Eureka Server Client-side bootstrap approaches Config Server discovery Repository backend types ...

    java8集合源码分析-app-engine-maven:应用引擎Maven

    多Profile支持,Gradle、Spring、应用程序Profile整合 完善的系统监控 热部署 自动生成接口文档 docker支持(gradle创建image、docker-compose) 环境配置 区分有三种环境dev、test、prod,不同环境会加载不同的配置...

    sonarqube-jacoco-maven-sample:简单的spring应用程序,配置用于报告单元和集成测试覆盖率,由jacoco提供给sonarqube

    SonarQube中的使用单位和集成测试覆盖率报告示例为了将jacoco报告发布到sonarqube,请使用您的凭据在本地〜/ .m2 / settings.xml文件中设置新的配置文件: &lt;profile&gt; &lt;id&gt;sonar&lt;/id&gt; &lt;activation&gt; &lt;activeByDefault&gt;...

    springboot学习思维笔记.xmind

    spring基础 Spring概述 Spring的简史 xml配置 注解配置 java配置 Spring概述 Spring的模块 核心容器CoreContainer Spring-Core Spring-Beans Spring-Context ...

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

    api-master是springMVC项目,基于maven多模块依赖,采用dubbo远程调用,目前spring升级到4.3.13版本,欢迎大家提出意见,您的宝贵意见,是我们进步的动力。 项目说明 项目基于maven的多profile环境配置,打包时需要...

    thymeleaf-tests-3.0-spring5.zip

    Tests included cover expressions, standard dialect attributes, Spring integration and also most of the example applications, among other topics. Tests under the org.thymeleaf.engine package are ...

    springboot通过@Profile注解配置不同环境

    通过当前案例和之前的maven 打包加载不同环境的配置文件内容;配合spring的@Profile注解配置在对于的class或者@Bean注解的方法上;来通过觉得某个拦截或者Java代码类是否生效

    JavaEE开发的颠覆者SpringBoot实战[完整版].part3

    在当今Java EE 开发中,Spring 框架是当之无愧的王者。而Spring Boot 是Spring 主推的基于“习惯优于配置”的原则,让你能够快速搭建应用的框架,从而使得Java EE 开发变得异常简单。 《JavaEE开发的颠覆者: Spring ...

    JavaEE开发的颠覆者SpringBoot实战[完整版].part2

    在当今Java EE 开发中,Spring 框架是当之无愧的王者。而Spring Boot 是Spring 主推的基于“习惯优于配置”的原则,让你能够快速搭建应用的框架,从而使得Java EE 开发变得异常简单。 《JavaEE开发的颠覆者: Spring ...

    y2p-maven-plugin

    y2p-maven-plugin说明该maven插件适用于spring boot微服务框架的目录结构,即YourProject src main java resources config application.yml application-dev.yml application-online.yml bootstrap.ymlMaven依赖...

    JavaEE开发的颠覆者SpringBoot实战[完整版].part1

    在当今Java EE 开发中,Spring 框架是当之无愧的王者。而Spring Boot 是Spring 主推的基于“习惯优于配置”的原则,让你能够快速搭建应用的框架,从而使得Java EE 开发变得异常简单。 《JavaEE开发的颠覆者: Spring ...

    高级java笔试题-spring-cloud-learning:spring-cloud、spring-cloud-alibaba、nacos

    然后你的服务跑起来,就可以跑通了,包括数据库,缓存,MQ这些东西,都可以在本地部署,有一个本地的maven profile,放这些配置。 或者是在公司内网环境里,提供几台机器,作为dev环境,部署了数据库、缓存、MQ等...

    基于springboot和docker部署的微服务架构.zip

    Maven 3.2+ Spring 4.1.3 Spring-boot 1.3.0.BUILD-SNAPSHOT j360 1.0.0.BUILD-SNAPSHOT ##j360-order## 直接使用Spring data jpa,省点力气写dao :) ###两种rest风格### @RepositoryRestResource...

Global site tag (gtag.js) - Google Analytics