2016-02-23 41 views
11

我想关闭ssl,到我的本地mysql数据库。 但我无法在spring.properties文件中找到实际属性。spring jpa application.properties useSSL

我的当前文件是:

# =============================== 
# = 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

+1

,因为它是默认情况下禁用你不需要做任何事情来关闭SSL([你必须添加'useSSL = true'到你的JDBC url并配置几个属性来启用它](https://dev.mysql.com/doc/connector-j/en/connector-j-reference-using-ssl。 HTML))。 –

+1

@AndyWilkinson感谢您的回复。我知道使用'useSSL = true',以后我会使用它。但是,我的问题是如何在spring application.properties文件中添加'useSSL = true/false'。你不能将它添加到我尝试过的datasource.url中,参见上文。 – SJC

回答

20

我固定在我下面的问题:“?”

jdbc:mysql://localhost:3306/test?verifyServerCertificate=false&useSSL=false&requireSSL=false 
0

你不是应该使用而不是“&”

这是你的

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

我想说的是

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