I build web application on grails,groovy which is interacting with 3 DB's MySql,Oracle(temporarily poining to H2),Mongo. Inorder to create dataSource I configured below properties
environments:
development:
dataSources:
dbCreate: create-drop
dataSource:
# local dev mysql db
url: "jdbc:mysql://localhost:3307/my_db?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC"
username: root
password: root
oraclerpt:
url: jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
# mongodb settings
grails:
mongodb:
url: "mongodb://localhost/my_db"
# port: 27017
# databaseName: "my_db"
test:
dataSources:
oraclerpt:
url: "jdbc:oracle:thin:@remoteIP:1521/my_db"
username: XXX
password: XXXX
formatSql: true
use_sql_comments: true
dataSource:
url: "jdbc:dataSource://RemoteAlias:3306/de_test"
username: XXX
password: XXXX
# mongodb settings
grails:
mongodb:
url: "mongodb://localhost/de_mfs_test"
# put settings here for deployment environments
production:
dataSources:
dataSource:
dbCreate: none
pooled: true
jmxExport: true
driverClassName: "com.mysql.cj.jdbc.Driver"
dialect: org.hibernate.dialect.MySQL5InnoDBDialect
properties:
jmxEnabled: true
initialSize: 5
maxActive: 50
minIdle: 5
maxIdle: 25
maxWait: 10000
maxAge: 600000
timeBetweenEvictionRunsMillis: 5000
minEvictableIdleTimeMillis: 60000
validationQuery: SELECT 1 FROM DUAL
validationQueryTimeout: 3
validationInterval: 15000
testOnBorrow: true
testWhileIdle: true
testOnReturn: false
jdbcInterceptors: ConnectionState
defaultTransactionIsolation: 2 #
When i am build this getting below errors
2016-12-26 12:15:58,276 ERROR localhost-startStop-1 org.springframework.boot.context.embedded.tomcat.TomcatStarter - Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException. Message: Error creating bean with name 'filterInvocationInterceptorFilterDeregistrationBean': Cannot resolve reference to bean 'filterInvocationInterceptor' while setting bean property 'filter'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'filterInvocationInterceptor': Cannot resolve reference to bean 'authenticationManager' while setting bean property 'authenticationManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationManager': Cannot resolve reference to bean 'daoAuthenticationProvider' while setting constructor argument with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'daoAuthenticationProvider': Cannot resolve reference to bean 'userDetailsService' while setting bean property 'userDetailsService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDetailsService': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'transactionManager_dbCreate' while setting constructor argument with key [3]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager_dbCreate': Cannot resolve reference to bean 'dataSource_dbCreate' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'dataSource_dbCreate' is defined
2016-12-26 12:15:58,479 ERROR main org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter -
***************************
APPLICATION FAILED TO START
***************************
Description:
A component required a bean named 'dataSource_dbCreate' that could not be found.
Action:
Consider defining a bean named 'dataSource_dbCreate' in your configuration.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':bootRun'.
> Process 'command 'C:\Program Files\Java\jdk1.8.0_111\bin\java.exe'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Error |
Failed to start server (Use --stacktrace to see the full trace)
Process finished with exit code 1
You are using dbCreate
in wrong block, that's why it's trying to create dataSource_dbCreate:
environments:
development:
dataSources:
dbCreate: create-drop
dataSource:
Move it under specified dataSource:
environments:
development:
dataSources:
dataSource:
dbCreate: create-drop
Check out also official docs with example.