spring-security-react-ant-design-polls-app
spring-security-react-ant-design-polls-app copied to clipboard
@EntityScan(basePackageClasses = {Jsr310JpaConverters.class})
Hi @callicoder
When I add config @EntityScan(basePackageClasses = {Jsr310JpaConverters.class})
to Application
class.
and add method init()
. The bellow error has occurred. And not started Tomcat.
@PostConstruct
void init() {
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
}
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'securityConfiguration': Unsatisfied dependency expressed through field
'userDetailsService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'userDetailsService': Unsatisfied dependency expressed through field 'userService';
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name
'userService': Unsatisfied dependency expressed through field 'userRepository';
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'userRepository': Invocation of init method failed;
nested exception is java.lang.IllegalArgumentException: Not a managed type: class example.database.entry.User
I have solved. Because I forgot to add Application.class
to @EntityScan
.
When login perform error has occurred.
Can't cast String to UserPrincipal
in the method generaterToken();
When I have performed signin, the bellow error has occurred.
org.springframework.security.authentication.BadCredentialsException: Bad credentials
at org.springframework.security.authentication.dao.DaoAuthenticationProvider.additionalAuthenticationChecks(DaoAuthenticationProvider.java:89) ~[spring-security-core-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider.authenticate(AbstractUserDetailsAuthenticationProvider.java:166) ~[spring-security-core-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:174) ~[spring-security-core-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:199) ~[spring-security-core-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter$AuthenticationManagerDelegator.authenticate(WebSecurityConfigurerAdapter.java:512) ~[spring-security-config-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at example.service.impl.LoginServiceImpl.login(LoginServiceImpl.java:69) ~[classes/:na]
at example.sso.auth.LoginController.authenticateUser(LoginController.java:63) ~[classes/:na]
DaoAuthenticationProvider.java:89
if (!passwordEncoder.matches(presentedPassword, userDetails.getPassword())) {
logger.debug("Authentication failed: password does not match stored value");
throw new BadCredentialsException(messages.getMessage(
"AbstractUserDetailsAuthenticationProvider.badCredentials",
"Bad credentials"));
}