Click here to Skip to main content
15,946,342 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone, please I have a spring boot application in Intellij Idea and I added the dependencies for spring security and thymleaf extras spring boot security to my pom.xml file but it's not working in Intellij community edition. I have done a maven update/reload, build, clean and validate from Intellij but non of these commands worked, please how can get spring security and thymleaf extras spring boot dependencies to work in Intellij ? Thanks for any help.

What I have tried:

I've added the following dependencies to my pom.xml file.
<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-test</artifactId>
    <scope>test</scope>
</dependency>

<dependency>
    <groupId>org.thymeleaf.extras</groupId>
    <artifactId>thymeleaf-extras-springsecurity6</artifactId>
</dependency>
Posted

IntelliJ doesn't do anything magical. It's an ide, not a code rewrite, so the problem isn't in Intellij. If you do manage clean install, you're going to build exactly the same code as you would ny clicking build, as long as you've pointed to the same jdk in both.

Looking at your pom file, you have scope spring security to test, so it's not going to have any effect on the runtime code.

Now for the biggie. When you say it doesn't work, we have no context to understand what you mean by that. Is it that you get an error? Do you not see any effect? Does your left arm turn blue? We can't see your screen so we don't know what's happening. Simply adding entries into a pom file doesn't actually accomplish much, other than give you code you might call, so we are missing context. Update your question to add a lot more detail and we might be able to provide some support.
 
Share this answer
 
Comments
Andre Oosthuizen 29-Jun-24 8:57am    
On the head Pete, "doesn't work' is very vague and leaves scope for so many different answers.

@OP, maybe this link will help - https://stackoverflow.com/questions/32917308/how-to-make-thymeleaf-spring-security-namespace-available
UT7 29-Jun-24 9:39am    
@Pete O'Hanlon, @Andre Oosthizen. Sorry for not adding more details. By adding spring security dependency to a project it should automatically secure all endpoints that a project has and generate a password which I would be able to use for logging into the application, the default username is user, so what I meant by "it didn't work" was that the password that ought to be generated wasn't generated although the spring boot application compiled without any errors after I have added all the necessary dependencies as I've stated above.
Pete O'Hanlon 29-Jun-24 16:20pm    
Thymeleaf still needs code. Check this article for an example. https://www.baeldung.com/spring-security-thymeleaf
@Pete O'Hanlon thanks, I've resolved it, I got help from someone. I had to replace this dependency
<dependency>
	<groupId>org.springframework.security</groupId>
	<artifactId>spring-security-test</artifactId>
	<scope>test</scope>
</dependency>

with this -
<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-security</artifactId>
</dependency>

In the first dependency above spring security scope was set to test which can only be used for Unit Testing but for a regular spring security application, the second dependency was to be used. Thanks @Pete O'Hanlon and @Andre Oosthuizen. Issue resolved.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900