JetBrains / kotless

Kotlin Serverless Framework
Apache License 2.0
1.15k stars 58 forks source link

spring - jpa data support #126

Open mamaorha opened 1 year ago

mamaorha commented 1 year ago

I wasn't able to add jpa properly to the project, it works locally but when deployed there were missing beans and it kept on failing. eventually i removed the jpa and defined the data source bean manually.

(note the System.getEnv is an additional hack since loading application.yaml isnt working as well - i opened a diff issue on that matter)

@Bean
    open fun dataSource(): DataSource {
        val hikariConfig = HikariConfig().apply {
            this.isAutoCommit = true
            this.driverClassName = "com.mysql.cj.jdbc.Driver"
            this.jdbcUrl = System.getenv()["MYSQL_HOST"]
            this.username = System.getenv()["MYSQL_USER"]
            this.password = System.getenv()["MYSQL_PASS"]
            this.connectionTimeout = 60000
            this.validationTimeout = 60000
            this.maximumPoolSize = 50
        }

        return HikariDataSource(hikariConfig)
    }