在 spring boot 2.0.2 中禁用 spring security

aZg*_*dou 4 spring-security spring-boot

我试图通过添加security.ignore=/**属性来禁用 spring boot 2.0.2 中的 spring 安全性,但它对我不起作用。

我的 application.properties:

spring.datasource.url = jdbc:mysql://localhost:3306/smile
spring.datasource.username = root
spring.datasource.password =
spring.datasource.driverClassName = com.mysql.jdbc.Driver
spring.jpa.hibernate.ddl-auto = update
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect

# suppress inspection "SpringBootApplicationProperties"
security.ignored=/**
Run Code Online (Sandbox Code Playgroud)

结果:

在此处输入图片说明

小智 5

在您的主文件 spring boot 应用程序中添加此 Java 注释。

@EnableAutoConfiguration(exclude = { 
    SecurityAutoConfiguration.class 
})
Run Code Online (Sandbox Code Playgroud)