其实记住我默认实现是在内存中的,点开这个类可以看到 org.springframework.security.web.authentication.rememberme.InMemoryTokenRepositoryImpl
@Bean
public PersistentTokenRepository persistentTokenRepository() {
JdbcTokenRepositoryImpl jdbcTokenRepository = new JdbcTokenRepositoryImpl();
jdbcTokenRepository.setCreateTableOnStartup(true);
//这一行报错,原因缺少JDBC依赖
jdbcTokenRepository.setDataSource(dataSource);
return jdbcTokenRepository;
}
maven 中找一下,在pom.xml中加入即可解决
https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-jdbc/2.1.5.RELEASE
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-jdbc -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<version>2.1.5.RELEASE</version>
</dependency>
转载于:https://www.jianshu.com/p/999678a760fb