我试图让我的.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