0
votes

I have a project consisting of, say, 10 modules. These modules are normal Java modules that use spring beans for dependencies.

I'm aware that when I define my spring config files, upon building, spring will find beans from other modules if they are referenced in a config file, so this makes life very easy for separation of config files.

However, I have now made a new module, which is a spring mvc web module. I still want to reference various config files from the other Java modules, but am unaware how to do this. I have tried defining classpath*: in the servlet file but all it seems to allow me to do is get files within the current module.

Here is a visualisation of 2 modules:

-- MVC Module --

----- src -> main -> java code -----

----- web -> WEB-INF -> servlet/context files -----

-- Separate Java Module --

----- src -> main -> spring resource file -----

So from my MVC module web folder, I want to access the separate java module spring files.

Can I do this??

Thanks

1

1 Answers

2
votes

If this is a maven based project then in your web module's pom.xml you will have to add the java module as a dependency. Your configuration files must exist in src/main/resources as by default only src/main/java and src/main/resources are contained in the jar.

<dependency>
        <groupId>com.java.module</groupId>
        <artifactId>java-module</artifactId>
        <version>1.0.0</version>
</dependency>

Note that all the dependencies in java module will be included in your web module when you add the dependency.