我試圖讓我的.properties文件讀取properties-maven-plugin。 Flyway(即時嘗試使用屬性)只是不斷拋出有關數據庫網址格式錯誤的錯誤,但工程如果我在pom.xml本身設置值,而不是使用從文件讀取的屬性。Maven讀取.properties在pom.xml中使用
Im使用eclipse與m2e插件。
插件配置以從讀取的.properties
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>src/main/resources/config.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
遷飛config其中的屬性正在使用位於/ SRC /主/資源
<plugin>
<groupId>com.googlecode.flyway</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>flyway:migrate</goal>
</goals>
</execution>
</executions>
<configuration>
<driver>${db.driver}</driver>
<url>${db.url}</url>
<user>${db.user}</user>
<password>${db.password}</password>
</configuration>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.26</version>
</dependency>
</dependencies>
</plugin>
config.properties/
# Database details
db.driver=com.mysql.jdbc.Driver
db.url=jdbc:mysql://localhost:3306/dbname
db.user=username
db.pass=password
我試圖通過幾個其他的stackoverflow線程,但沒有解決方案s eem工作。我對maven很陌生,整個事情似乎都在拋我,任何人都會有光芒流下來?
是否Eclipse之外工作?當你簡單地運行'mvn'命令? –
仍然有相同的「參數」url「丟失或無效」 – Wader
嘗試查看Flyway的日誌文件(如果存在的話)中傳遞給Flyway的參數。另外從Flyway網站上查看一些示例,可以看出DB數據庫存在細微差別: 「jdbc:sqlserver:// prodDB:1040; databaseName = flyway_prod」。所以我建議你嘗試「jdbc:mysql:// localhost:3306; databaseName = dbname」,雖然你說過直接指定參數params ... – hovanessyan