我已经在我的pom.xml文件中添加了spring安全依赖项,但无法在控制台上看到我的默认密码。我添加了以下依赖项
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
我的主类看起来像
@EnableAutoConfiguration
@EntityScan(basePackages={"com.gonkar.fleetms.models"})
@EnableJpaRepositories(basePackages={"com.gonkar.fleetms.repositories"})
@SpringBootApplication(scanBasePackages= {"com.gonkar.fleetms"})
public class FleetManagementSytemApplication {
public static void main(String[] args) {
SpringApplication.run(FleetManagementSytemApplication.class, args);
}
}
我尝试在属性文件中添加以下属性,但没有运气logging.level.org.springframework.security=INFO
我尝试添加的控制台上没有打印密码
spring.security.user.name=user
spring.security.user.password=pwd
但不走运,它没有从属性文件中阅读上述属性。
注意:我不知道为什么,但是当我从主类中删除componentScan注解时,它开始在控制台打印默认密码。根据我的观察,当我使用componentScan注解时,它不会在控制台上打印默认密码
3条答案
按热度按时间nimxete21#
试试下面的属性,看看是否有效。
或
pxyaymoc2#
禁用application.properties或application.yml中的设置
myzjeezk3#
如果你使用InMemoryUserDetailsManager来创建一个配置类,Spring Security 将不会显示任何密码。您需要使用使用UserDetails创建的用户的凭据