编辑:如果你否决了我的投票,那么请至少评论一下为什么。
我正试图通过在pom.xml中使用maven概要文件,将特定的细节注入到我的datasource.properties文件中
出于某种原因,它将详细信息应用于其他需要的地方,例如hibernate.cfg.xml,但它没有将其应用于我的datasource.properties?
我已经添加了资源所在位置的配置,但不确定我缺少什么?
这是我的pom.xml中的相关信息
.......
<profiles>
<profile>
<id>development</id>
<activation>
<activeByDefault>true</activeByDefault>
<property>
<name>environment</name>
<value>dev</value>
</property>
</activation>
<properties>
<db.username>some username</db.username>
<db.password>some password</db.password>
<db.url>some db url</db.url>
</properties>
</profile>
</profiles>
<properties>
<db.username>some username</db.username>
<db.password>some password</db.password>
<db.url>some db url</db.url>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<warName>APP</warName>
<webResources>
<resource>
<directory>src/main/webapp/META-INF</directory>
<filtering>true</filtering>
<targetPath>META-INF</targetPath>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/hibernate.cfg.xml</include>
<include>**/datasource.properties</include>
</includes>
</resource>
<resource>
<directory>src/main/webapp</directory>
<filtering>true</filtering>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
.......
以下是我的datasource.properties文件中的格式
datasource.driverClassName=some driver
datasource.url=${db.url}
datasource.username=${db.username}
datasource.password=${db.password}
datasource.initialPoolSize=10
datasource.minPoolSize=10
datasource.maxPoolSize=20
datasource.maxStatements=50