• Maven Profile标签


    Maven Profiles标签可以针对不同的环境来使用不同的配置文件
    在发布的时候可以用

    1. mvn release -p product
    2. mvn release -p test
    3. mvn release -p dev


    默认本地deploy的时候用的是dev的配置 文件

    在编译项目的过程中,资源中的占位符${}会被替换成配置文件中的值,如果没有进行替换,则会出现问题。


    <profiles>
    		<profile>
    			<id>product</id>
    			<build>
    				<filters>
    					<filter>src/main/resources/release.properties</filter>
    				</filters>
    			</build>
    		</profile>
    		<profile>
    			<id>dev</id>
    			<activation>
    				<activeByDefault>true</activeByDefault>
    			</activation>
    			<build>
    				<filters>
    					<filter>src/main/resources/dev.properties</filter>
    				</filters>
    			</build>
    		</profile>
    		<profile>
    			<id>test</id>
    			<build>
    				<filters>
    					<filter>src/main/resources/test.properties</filter>
    				</filters>
    			</build>
    		</profile>
    	</profiles>
    

    如果编译时资源文件中的占位符没有被替换成配置文件中的值,则一般会抛出异常:

    Circular placeholder reference 'db.url' in property definitions
            at org.springframework.beans.factory.config.PlaceholderConfigurerSupport.doProcessProperties(PlaceholderConfigurerSupport.java:209)
            at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(PropertyPlaceholderConfigurer.java:220)
            at com.showjoy.core.configure.SecPropertyPlaceholderConfigurer.processProperties(SecPropertyPlaceholderConfigurer.java:50)
            at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:84)
            at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:681)
            at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:656)
            at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:446)
            at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
            at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
            at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
            at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5003)
            at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5517)
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
            at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
            at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
            at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
            at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1095)
            at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1960)
            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
            at java.util.concurrent.FutureTask.run(FutureTask.java:266)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
            at java.lang.Thread.run(Thread.java:745)
    


    这时的处理办法是,把target中编译好的文件clean掉,重新用maven build下,确保资源文件中的占位符没有被替换成配置文件中的值



  • 相关阅读:
    基础JavaScript练习(一)总结
    零基础JavaScript编码(三)总结
    零基础JavaScript编码(二)
    零基础JavaScript编码(一)
    响应式网格(栅格化)布局总结
    实现常见的技术产品官网的页面架构及样式布局总结
    通过HTML及CSS模拟报纸排版总结
    任务四:定位和居中问题总结
    1. Two Sum
    任务三:三栏式布局总结
  • 原文地址:https://www.cnblogs.com/uwannerme/p/5692831.html
Copyright © 2020-2023  润新知