Spring Security
I dont know why but i am not getting default login page after enabling the @WebSecurity annoation ..
This is the classes and in the photo that is my project structure . Can anyone Help
61 Replies
⌛
This post has been reserved for your question.
Hey @Danix! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
What actually happens?
basically i have started spring security module and trying to start the basic security to my endpoint of the controllers via 2 classes called
SecurityConfiguration
and SecurityIntializer
but when i start the project then i didnot get any default login page for security purpose . I think the security page is automatically added to the project using the @Enable Web Security
annoatation right ?Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
Right now I am following a tutorial and that guy just got a login page for authentication and authorisation after just adding the two classes for config and initialisation as I mentioned above . So is that thing removed now bcz that video is 3 yrs old !
Can you show your pom.xml? I think the default login page is there only if you use Spring Boot
i am not using spring boot now either i am using spring mvc instead
What should be the right ?
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
I have already given the pom.xml
@dan1st | Daniel
That's Spring 6. They are using Spring 5.
Can you try overriding the configure method in your WebSecurityConfigurerAdapter and add
.formLogin()
there?Which one ?
Which are available?
Btw Spring 5 will be out of Open Source support soon
Hmm so I have to use spring 6 for my upcoming projects ?
I would strongly recommend doing that
i did it but not get anything its same
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
This is my controller for checking is this Ok ?
@Sammi[OG]
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
Alright waiting for the response
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
it just means what you return is converted to text and sent back to the user
If you don't have
@ResponseBody
, it typically tries to render the responseI have already added the responseBody annotation
Then whats the issue why the default login page is not showing after hitting the /hii endpoint
@ResponseBody
won't show any login page ok now i have removed it and also added a hi.jsp to the retrun but still i can access the jps page or u can say /hii endpoint
Is your security configuration attempting to prevent that in any way?
Wdym ?
Why should it not be accessible?
This is what I did
You called your package
config
?
Can you show your beans.xml?Yehh
Beans.xml ?
Do you have such a file?
Spring doesn't scan all packages, it only scans package under some root package
No
I have web.xml
and if something isn't in that root package, Spring won't find it
So Spring doesn't know anything about your
Config
classI think no !
that was a typo
I wanted to write
So
instead of Do
this wasn't a question
you see the base-package="com.controllers"
?
That means Spring will only find stuff in com.controllers is this ok
Why don't you just create one common package and put all your application classes in subpackages?
but the issue is still same
no
if your base package is
com.yourapplication
and you have classes in °com.yourapplication.controllers and
com.yourapplication.config`, these should be detectedPackage are not scanning
you need to set it to
com.application
not com.application.*
Still 404 error
Do you have a handler for that?
Yess /hii
And you are accessing /hii in your browser?
How are you running the application?
Do you have a servers view in Eclipse?
like this ?
when i write this in scan com.applicationcom.controllers then it works but not with com.applicationcom
com.application
not com.applicationcom
but ig if it works, it's finei did the same project on spring boot and it runs perfectly @dan1st | Daniel
some one said to me that WebsecurityConfigurerAdapter is deprecated…
is deprecated is that real ?
It is in Spring 6
So the concepts are same or just changed ?
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
What did I said wrong?
?
He blocked me or removed from friends. I want to get him back. tried to search from history.
and you think pinging them would result in a notification?
Anyways, please don't try to contact people that blocked you via this Discord.
ok. Lock this question.
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.