0

I am working on a spring boot application with maven dependency on spring-session-data-redis. I would like to customize the createSession() of MapSession class in spring-sessions.

As this is now not supported in spring-sessions. So I have cloned this spring-sessions repo and customized this according to my requirement. Then I built this and replaced the existing spring-session-data-redis jar in BOOT_INF/lib of my original spring-boot application project with this new spring-session-data-redis jar.

Dependency graph of my original maven project is as follows:

my_project
   |
    +- org.springframework.session:spring-session-data-redis:jar:2.3.0.RELEASE:compile
  
        |  \- org.springframework.session:spring-session-core:jar:2.3.0.RELEASE:compile

Now while I loaded the project in IDE, I am still seeing flow is going to MapSession class in an old spring-sessions-core jar which is located in .m2/repository.

Being new to maven, I don't have much idea how to do this. In this regard, I have gone through this: How to manually install an artifact in Maven 2?. But cannot understand how to fix this. Could anyone please help here? Thanks.

Joy
  • 4,197
  • 14
  • 61
  • 131
  • That means you have to use a different version of spring boot which handles all that. You could also overwrite a version of a particular dependency in your pom but I strongly discourage that. – khmarbaise Jul 18 '20 at 06:36
  • Hi @khmarbaise as I mentioned, this not supported as of now in spring-session ( https://github.com/spring-projects/spring-session/issues/11). So I had to take this approach. – Joy Jul 18 '20 at 07:04

2 Answers2

1

Delete the entire maven .m2/reoository folder from your ${user.home} folder. Then run mvn clean install to redownload all the latest dependencies.

DV82XL
  • 5,350
  • 5
  • 30
  • 59
  • thanks for your response. But I don't want to redownload the particular dependency, instead, I want to use the newly built one as I mentioned in OP. – Joy Jul 18 '20 at 06:16
  • @Joy When you cloned the spring-sessions repo, did you modify the POM.xml file to give it a new version? You would also have to update the dependency version in your application's POM.xml. I'm not sure that just copying the jar over without properly managing dependencies is the best approach – DV82XL Jul 20 '20 at 12:57
  • Looks like you solved this issue though, is that correct? – DV82XL Jul 20 '20 at 12:58
1

You can use maven install with -U option. Example: mvn clean install -U

-U (--update-snapshots) 
    Forces a check for updated releases and snapshots on remote repositories

More such useful options