Create the application
mn create-app my-app -l groovy -f http-client,hibernate-gorm
cd my-app/
mn create-controller HelloController
./gradlew run
open the link in the browser
http://localhost:8080
To Connect to MySQL Add this in the application.yaml file
---
micronaut:
application:
name: webapp
server:
port: 8080
---
datasources.default: {}
---
hibernate:
hbm2ddl:
auto: update
cache:
queries: false
use_second_level_cache: true
use_query_cache: false
region.factory_class: org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory
dataSource:
url: jdbc:mysql://localhost:3306/db
dbCreate: create-update
pooled: true
jmxExport: true
driverClassName: com.mysql.cj.jdbc.Driver
dialect: org.hibernate.dialect.MySQL5InnoDBDialect
username:
password:
Make sure you have these entry in build.gradle file
compile "io.micronaut.configuration:micronaut-jdbc-tomcat"
compile "io.micronaut.configuration:micronaut-hibernate-validator"
compile "io.micronaut.configuration:micronaut-hibernate-gorm"
compile "org.grails:grails-datastore-gorm-hibernate5:6.1.9.RELEASE"
runtime "org.hibernate:hibernate-ehcache:5.1.9.Final"
runtime group: 'mysql', name: 'mysql-connector-java', version: '8.0.13'