I am trying to deploy my springboot app to heroku but I am getting an error that it cannot find a JwtDecoder bean. I have tried googling it a bit but can’t find anything that helps. Everything works fine locally, just not when deployed to heroku.
Here is my heroku log –tail:
2021-02-27T20:18:45.134160+00:00 app[web.1]: *************************** 2021-02-27T20:18:45.134160+00:00 app[web.1]: APPLICATION FAILED TO START 2021-02-27T20:18:45.134160+00:00 app[web.1]: *************************** 2021-02-27T20:18:45.134161+00:00 app[web.1]: 2021-02-27T20:18:45.134161+00:00 app[web.1]: Description: 2021-02-27T20:18:45.134161+00:00 app[web.1]: 2021-02-27T20:18:45.134179+00:00 app[web.1]: Method springSecurityFilterChain in org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration required a bean of type 'org.springframework.security.oauth2.jwt.JwtDecoder' that could not be found. 2021-02-27T20:18:45.134179+00:00 app[web.1]: 2021-02-27T20:18:45.134179+00:00 app[web.1]: 2021-02-27T20:18:45.134180+00:00 app[web.1]: Action: 2021-02-27T20:18:45.134180+00:00 app[web.1]: 2021-02-27T20:18:45.134181+00:00 app[web.1]: Consider defining a bean of type 'org.springframework.security.oauth2.jwt.JwtDecoder' in your configuration.
WebSecurityConfig:
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception{
http.csrf().disable().cors().configurationSource(corsConfigurationSource())
.and()
.authorizeRequests()
.antMatchers("/*")
.authenticated()
.and()
.oauth2ResourceServer()
.jwt();
}
I’m not sure what else to include… Feel free to comment on what else I should add. Or, the repo is at https://github.com/AndreTheTallGuy/Kelp2
Thank you in advance for any help you may be able to provide!
Advertisement
Answer
It cannot find org.springframework.security.oauth2.jwt.JwtDecoder because you listed that dependency as test scope
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
Change the scope or just remove that entry. Default entry is compile.
