我有3个maven项目A、B、C。A是B的父项目,B是C的父项目。所有概要文件都在pom中定义。项目A的xml。
在项目C中,我试图根据所选概要文件在spring测试上下文中选择属性文件(在src/test/resources下)。对于回归测试,我们有两个属性文件:
在我们的Windows开发系统上,选定的配置文件将是“本地”的,相应地在服务器上也是如此。选择“本地”配置文件时,应使用application-test-local.properties
和application-test.properties
,否则在测试Spring上下文中。在项目C中,在spring-test-context.xml
中,我尝试了:
<beans profile="docker">
<util:properties id="metaDbProps" location="application-test-local.properties"/>
</beans>
<beans profile="default">
<util:properties id="metaDbProps" location="application-test.properties"/>
</beans>
然而,应用程序似乎无法将所选的maven概要文件传递给spring概要文件,因为我正在尝试“mvn clean test-Pdocker”,并且它总是从“default”概要文件中提取属性文件。
您知道如何将maven概要文件传递给spring概要文件,以便它能够获取正确的属性文件吗?
为便于理解,以下是如何在项目A中定义概要文件:
<profiles>
<!-- Windows development -->
<profile>
<id>docker</id>
<activation/>
<properties>
<INSTALL_MACHINE_LIST>localhost</INSTALL_MACHINE_LIST>
<COPY_MODE>local</COPY_MODE>
</properties>
</profile>
<!-- Development -->
<profile>
<id>dev</id>
<activation/>
<properties>
<INSTALL_MACHINE_LIST>dev01</INSTALL_MACHINE_LIST>
</properties>
</profile>
<!-- QA -->
<profile>
<id>qa</id>
<activation/>
<properties>
<INSTALL_MACHINE_LIST>dqa01</INSTALL_MACHINE_LIST>
</properties>
</profile>
<!-- Production -->
<profile>
<id>prod</id>
<activation/>
<properties>
<INSTALL_MACHINE_LIST>prod01</INSTALL_MACHINE_LIST>
</properties>
</profile>
</profiles>
默认情况下,Maven测试使用Maven Surefire插件运行。您可以将Spring配置文件声明为Maven配置文件中的属性:
<profile>
<id>docker</id>
<properties>
<spring.profiles.active>docker</spring.profiles.active>
</properties>
</profile>
然后使用将其传递给Surefire
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Dspring.profiles.active=@{spring.profiles.active} @{argLine}</argLine>
</configuration>
</plugin>
</plugins>
</build>
请注意
@{...}
语法:
自2.17版使用argLine的替代语法以来,@{…}允许在执行插件时延迟替换属性,以便正确获取已被其他插件修改的属性
我有2个URL,其中1个特定于Dev,另一个特定于Prod。我也在使用Spring profiling,其中我有一个单独的文件用于Dev和Prod application-Dev。性能和应用-prod。属性和我的应用。对于Dev env,属性文件如下所示 spring.profiles.active=dev 现在在我的java代码中,我想有一个属性,它将根据我使用的Spring配置文件绑定到适当的
我有两个Spring概要文件:和。我想在服务器环境中设置活动配置文件,但我不想在代码中设置它,以便在部署应用程序的任何地方,配置文件都是基于服务器中的配置文件加载的。我怎么能那样做?
主要内容:1. outline-style,2. outline-width,3. outline-color,4. outline,5. outline-offset轮廓(outline)是绘制于元素周围的一条线,位于边框的外围(紧贴着边框),主要用来突出显示某个元素,如下图所示: 图:轮廓(outline) 轮廓和边框看起来非常相似,但它们之间也并非没有区别,例如: 元素上下左右四个方向上边框的样式、宽度、颜色可以单独设置,而轮廓在元素四个方向的宽度、样式、颜色都是相同的,不能单独设置; 边
基于这篇文章,我运行我的Spring Boot应用程序 具有该配置文件的组件不运行。我尝试用根应用程序类中的以下代码来验证活动概要文件 日志消息输出为空。 少了什么?
我有一些按钮使用,当点击它时得到一个蓝色的选定颜色! 有没有一种方法可以移除这个功能?
如图,如何给透明背景的canvas图片的轮廓描边。 尝试过几个方案,但是达不到想要的效果