Grails 4 - application.groovy ou application.yml
20/08/2019 16:09
0
Prezados,

Estou tentando configurar um acesso a Microsoft SQL Server, retirando do projeto o H2DB que eu vinha usando até aqui para fins de teste.

Ao pesquisar na internet, vi várias pessoas falando no arquivo application.groovy. Só que no meu projeto, o arquivo que foi criado com o projeto foi o application.yml dentro de grails-app.

No arquivo YML tem uma seção de configuração com oi banco, mas está dando problema na configuração. Alguém aí tem algum arquivo exemplo de configuração do SQL Server no Grails 4?


Isso foi o que eu coloquei no arquivo application.yml. Perceba que eu comentei a parte do H2 que vem por padrão no projeto.

dataSource:
    pooled: true
    jmxExport: true
    driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
    username: sa
    password: senhaDefault
environments:
    development:
        dataSource:
            #dbCreate: create-drop
            #url: jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE            
            dbCreate = create-drop
            driverClassName = com.microsoft.sqlserver.jdbc.SQLServerDriver
            url= jdbc:sqlserver://IPINTERNO:1431;databaseName=ID;domain=MSSQLSERVER01
            username = sa
            password = senhadefault
    test:
        dataSource:
            dbCreate: update
            url: jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
    production:
        dataSource:
            dbCreate: none
            url: jdbc:h2:./prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
            properties:
                jmxEnabled: true
                initialSize: 5
                maxActive: 50
                minIdle: 5
                maxIdle: 25
                maxWait: 10000
                maxAge: 600000
                timeBetweenEvictionRunsMillis: 5000
                minEvictableIdleTimeMillis: 60000
                validationQuery: SELECT 1
                validationQueryTimeout: 3
                validationInterval: 15000
                testOnBorrow: true
                testWhileIdle: true
                testOnReturn: false
                jdbcInterceptors: ConnectionState
                defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED




Olha o erro....

2019-08-20 12:56:47.494 ERROR --- [  restartedMain] o.s.boot.SpringApplication               : Application run failedorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateDatastore': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.grails.orm.hibernate.HibernateDatastore]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException        at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:304)        at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:285)        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1341)        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1187)        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)        at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:392)        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1321)        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1160)        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:845)        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877)        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:742)        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:389)        at org.springframework.boot.SpringApplication.run(SpringApplication.java:311)        at grails.boot.GrailsApp.run(GrailsApp.groovy:97)        at grails.boot.GrailsApp.run(GrailsApp.groovy:458)        at grails.boot.GrailsApp.run(GrailsApp.groovy:445)        at cmbiddocumentproperties.Application.main(Application.groovy:11)        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)        at java.lang.reflect.Method.invoke(Method.java:498)        at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.grails.orm.hibernate.HibernateDatastore]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException        at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:184)        at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:117)        at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:300)        ... 34 common frames omittedCaused by: java.lang.IllegalArgumentException: null        at sun.reflect.GeneratedMethodAccessor74.invoke(Unknown Source)        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)        at java.lang.reflect.Method.invoke(Method.java:498)        at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:282)        at org.grails.datastore.mapping.config.ConfigurationBuilder.buildRecurse(ConfigurationBuilder.groovy:360)        at org.grails.datastore.mapping.config.ConfigurationBuilder.buildRecurse(ConfigurationBuilder.groovy:238)        at org.grails.datastore.mapping.config.ConfigurationBuilder.buildRecurse(ConfigurationBuilder.groovy:286)        at org.grails.datastore.mapping.config.ConfigurationBuilder.buildInternal(ConfigurationBuilder.groovy:111)        at org.grails.datastore.mapping.config.ConfigurationBuilder.build(ConfigurationBuilder.groovy:92)        at org.grails.orm.hibernate.connections.HibernateConnectionSourceSettingsBuilder.build(HibernateConnectionSourceSettingsBuilder.groovy:37)        at org.grails.orm.hibernate.connections.AbstractHibernateConnectionSourceFactory.buildSettings(AbstractHibernateConnectionSourceFactory.java:70)        at org.grails.orm.hibernate.connections.AbstractHibernateConnectionSourceFactory.buildSettings(AbstractHibernateConnectionSourceFactory.java:23)        at org.grails.datastore.mapping.core.connections.AbstractConnectionSourceFactory.create(AbstractConnectionSourceFactory.java:63)        at org.grails.datastore.mapping.core.connections.AbstractConnectionSourceFactory.create(AbstractConnectionSourceFactory.java:52)        at org.grails.datastore.mapping.core.connections.ConnectionSourcesInitializer.create(ConnectionSourcesInitializer.groovy:24)        at org.grails.orm.hibernate.HibernateDatastore.<init>(HibernateDatastore.java:200)        at sun.reflect.GeneratedConstructorAccessor46.newInstance(Unknown Source)        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)        at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:172)        ... 36 common frames omitted
Tags: Grails


0
Verifique se sua instalação do SQL Server está com a comunicação do tipo TCP habilitada.



Ainda não faz parte da comunidade???

Para se registrar, clique aqui.


Aprenda Groovy e Grails com a Formação itexto!

Newsletter Semana Groovy

Assinar

Envie seu link!


Livro de Grails


/dev/All

Os melhores blogs de TI (e em português) em um único lugar!

 
Creative Commons
RSS Grails Brasil é mantido por itexto Consultoria.
Em caso de problemas contacte Henrique Lobo Weissmann (Kico) por e-mail: kico@itexto.com.br
Todo o conteúdo presente neste site adota o Creative Commons como licença padrão.
Ver: 4.14.0
itexto