我正在尝试根据使用 maven 选择的配置文件将我的资源复制到类路径中。我的资源文件夹结构如下:
src/main/resources:
config
production
development
staging
我当前不工作的配置是
<profile>
<id>development</id>
<activation>
<activeByDefault>true</activeByDefault>
<property>
<name>envtype</name>
<value>dev</value>
</property>
</activation>
<build>
<finalName>Corelay</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
</includes>
<excludes>
<exclude>**/production/**</exclude>
<exclude>**/staging/**</exclude>
</excludes>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
</includes>
<excludes>
<exclude>**/production/**</exclude>
<exclude>**/staging/**</exclude>
</excludes>
</testResource>
</testResources>
</build>
</profile>
在 config/hibernate/hibernate-config.xml 下的休眠配置文件中,我从同一个包中请求一些属性
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath*:**/jdbc.properties</value>
<value>classpath*:**/hibernate.properties</value>
</list>
</property>
</bean>
但有一个错误:
Could not resolve placeholder 'jdbc.driverClassName' in string value "${jdbc.driverClassName}"
此属性在该文件中定义。怎么了?另一个问题是如何使从这些配置文件文件夹中复制的资源出现在完全相同的输出类路径结构中?我的意思是不应该有 /production、/development 或 /staging :只有 /env
我知道我可以将它们单独放入,但是如果有共享的(如呈现的结构中的配置),我怎么能包含它呢?