我已经分离了dataSourceConfig.yml数据库配置文件:
environments:
development:
dataSource:
dbCreate: none
url: jdbc:oracle:thin:xxxxxx
driverClassName: oracle.jdbc.OracleDriver
dialect: org.hibernate.dialect.Oracle10gDialect
username: xxxx
password: xxxx
test:
dataSource:
dbCreate: none
url: jdbc:oracle:thin:xxxxx
driverClassName: oracle.jdbc.OracleDriver
dialect: org.hibernate.dialect.Oracle10gDialect
username: xxxxx
password: xxxxx它连接到Application.java中的项目。
class Application extends GrailsAutoConfiguration implements EnvironmentAware {
static void main(String[] args) {
GrailsApp.run(Application, args)
}
@Override
void setEnvironment(Environment environment) {
String configPath = environment.getProperty("local.config.location")
Resource resourceConfig = new FileSystemResource(configPath)
YamlPropertiesFactoryBean ypfb = new YamlPropertiesFactoryBean()
ypfb.setResources([resourceConfig] as Resource[])
ypfb.afterPropertiesSet()
Properties properties = ypfb.getObject()
environment.propertySources.addFirst(new PropertiesPropertySource("local.config.location", properties))
}
}当我通过Intellij 15运行集成测试时,它在开发环境下运行测试,但是YAML配置文件有测试部分。
有人知道怎么解决这个问题吗?命令吼叫没什么用。
grails test test-app -integration 发布于 2016-03-23 21:22:37
如果要从IDE运行测试,则需要修改run配置以包括-Dgrails.env=test。对于默认的JUnit运行配置,您将希望这样做,这样您就不必编辑每个测试运行配置。请注意,编辑默认的JUnit运行配置将影响将来创建的所有信任,但不会更新任何现有的信任。您可能希望删除所有现有的运行信任,以便在下次运行这些测试时使用新的设置重新创建它们。
https://stackoverflow.com/questions/36150913
复制相似问题