web-dev-qa-db-ja.com

spring jpa application.properties useSSL

ローカルmysqlデータベースへのsslをオフにしようとしています。しかし、これを行うSpring application.propertiesファイルで実際のプロパティを見つけることができません。

私の現在のファイルは:

# ===============================
# = DATA SOURCE
# ===============================

# Set here configurations for the database connection

# Connection url for the database "test"
spring.datasource.url = jdbc:mysql://localhost:3306/test
spring.datasource.driver-class-name=com.mysql.jdbc.Driver

# Username and password
spring.datasource.username = root
spring.datasource.password = blah

# Keep the connection alive if idle for a long time (needed in production)
spring.datasource.testWhileIdle = true
spring.datasource.validationQuery = SELECT 1

# ===============================
# = JPA / HIBERNATE
# ===============================

# Use spring.jpa.properties.* for Hibernate native properties (the prefix is
# stripped before adding them to the entity manager).

# Show or not log for each sql query
spring.jpa.show-sql = true

# Hibernate ddl auto (create, create-drop, update): with "update" the database
# schema will be automatically updated accordingly to Java entities found in
# the project
spring.jpa.hibernate.ddl-auto = update

# Naming strategy
spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy

# Allows Hibernate to generate SQL optimized for a particular DBMS
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect

私が試してみました spring.datasource.useSSl=falseそしてそれは動作しません。私も試してみましたspring.datasource.url = jdbc:mysql://localhost:3306/test&useSSL=false

18
SJC

以下の問題を修正しました。

jdbc:mysql://localhost:3306/test?verifyServerCertificate=false&useSSL=false&requireSSL=false
36
Sanjay Mistry

「?」を使用するべきではありませんの代わりに '&'

これはあなたの物です

spring.datasource.url =jdbc:mysql://localhost:3306/test&useSSL=false

私が言っているのは

spring.datasource.url = jdbc:mysql://localhost:3306/test?useSSL=false
1
Subhajit Roy

Javaオプションやシステムプロパティを汚染するのは好きではありません。これらはいずれにしてもアプリケーションコンテナでは役に立ちません...

以下を使用して、プログラムでMySQL接続のSSL証明書を設定できます。

jdbc:mysql://example.com:3306/MYDB?verifyServerCertificate = true&useSSL = true&requireSSL = true&clientCertificateKeyStoreUrl = file:cert/keystore.jks&clientCertificateKeyStorePassword = 123456&trustCertificateKeyStoreUrl = file:cert/truststore.jks&trustCertificateKeyStorePasswordStorePasswordPasswordPasswordPassword

文書化されています:

1
gavenkoa