• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Springboot multi module web application

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a multi module application where I have a parent application and then several child applications. I would like to reference javacscript from the parent module, but I can't seem to get it correctly.
has someone else done this in the past. I can't seem to get the correct syntax to get this to work.  I can reference java classes from the parent module but I cant reference other files? Any ideas.

This is my project set up.  Any help would be most appreciative.




 
Sheriff
Posts: 21758
102
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've done something like this but with data coming from other modules and even shared libraries, not the parent modules. The trick is where to put the resources. Anything you put in src/main/resources/public or src/main/resources/static will be available from the browser, with the actual path relative to these folders. So put something in one of these folders in the parent module, and your child modules should be able to get access to them. (The same thing holds for templates, in src/main/resources/templates.)

Now, if you don't want them to be accessible from the browser, just put them somewhere else under /src/main/resources. You can use Class and ClassLoader to get access to these resources, but also Spring (Boot)'s own resource loading.


Note that the above can only work if the child module has a runtime dependency on the parent module. That is often not the case though. You can introduce a new module with only this content instead.
 
migue abre
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Rob Spoor wrote:I've done something like this but with data coming from other modules and even shared libraries, not the parent modules. The trick is where to put the resources. Anything you put in src/main/resources/public or src/main/resources/static will be available from the browser, with the actual path relative to these folders. So put something in one of these folders in the parent module, and your child modules should be able to get access to them. (The same thing holds for templates, in src/main/resources/templates.)

Now, if you don't want them to be accessible from the browser, just put them somewhere else under /src/main/resources. You can use Class and ClassLoader to get access to these resources, but also Spring (Boot)'s own resource loading.


Note that the above can only work if the child module has a runtime dependency on the parent module. That is often not the case though. You can introduce a new module with only this content instead.




You are the man!!! Thank you for your response that’s exactly what I needed it to do. I’m very very  appreciative .
 
Rob Spoor
Sheriff
Posts: 21758
102
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!