我最近更新到 ActiveJDBC 2.1,以便使用 activejdbc.properties 来外部化数据库属性,这样我们就不必将数据库用户名/密码签入 SVN。
将主代码的“ activejdbc.property ”文件放在src/main/resources中效果很好。现在的目标是将测试目录src/test/resources中的“ database.property ”文件替换为“ activejdbc.property ”,这样它就可以指向文件系统上相同的数据库配置文件。
在测试目录中进行此更改后,我们在执行 gradle build (gradle clean build) 时收到错误。这是我们看到的异常:
`"org.javalite.activejdbc.InitException: java.io.FileNotFoundException: \database.properties (系统找不到指定的文件)"
任何想法为什么这适用于主目录但不适用于测试?
堆栈跟踪:es/main/com/brookdale/model/UnitOfMeasure.class **************************** END INSTRUMENTATION ***** *********************** ... :assemble :compileTestJava :processTestResources :testClasses :test
com.brookdale.model.ActualChargeTest > unitQuantityMustBeGreaterThanZero FAILED
org.javalite.activejdbc.InitException: java.io.FileNotFoundException: \database.properties (The system cannot find the file specified)
Caused by:
java.io.FileNotFoundException: \database.properties (The system cannot find the file specified)
... more tests ...
com.brookdale.service.RelationshipServiceTest > updateContactRel_GivenValidInfo_
RecordIsInserted FAILED
org.javalite.activejdbc.InitException: java.io.FileNotFoundException: \datab
ase.properties (The system cannot find the file specified)
Caused by:
java.io.FileNotFoundException: \database.properties (The system cannot f
ind the file specified)
49 tests completed, 25 failed, 7 skipped
:test FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':test'.
BUILD FAILED`