-
Notifications
You must be signed in to change notification settings - Fork 586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error starting Application: required a bean after adding jwt code #3
Comments
just add |
Hi, I added the @configuration and I am unable to access any file, I get 403 error and no token is generated |
try U can try not using
|
I apologize still very much a newbie, not sure what you mean.
…On Thu., Jul. 8, 2021, 3:50 p.m. Lucas Campos, ***@***.***> wrote:
try @component
U can try not using JwtConfig
just use
//Use @value with the name of the value in application.properties
//put this code inside any class that is initialized by SpringBoot, like @component @configuration etc...
@value("${application.jwt.token}")
private String tokenKey;
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#3 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQZO3JELQOEQZ5K7PDDYRYDTWX6QHANCNFSM44N4FVQQ>
.
|
Adding the |
I will try adding that and see. Thank you.
…On Wed., Jul. 14, 2021, 6:59 a.m. Mátis Szilárd Gábor, < ***@***.***> wrote:
Adding the @component annotation inside the JwtConfig class solves the
issue for me.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#3 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQZO3JCPOAEXXPUZVV4EPKLTXVUZ3ANCNFSM44N4FVQQ>
.
|
This is happening if you use any spring-boot release higher than 2.2.0 used by Nelson. So the code in this repository will compile fine. But if you use a new release then you can add @component annotation to JwtConfig class in order to be recognized as a Bean and be auowired. package com.aelamine.sprintbootsecurity.jwt; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; import com.google.common.net.HttpHeaders; @ConfigurationProperties(prefix = "application.jwt") @Component public class JwtConfig { private String secretKey; ... |
Using only @component annotation solved the issue
|
The text was updated successfully, but these errors were encountered: