0

I have a project that have dependency to other project like this:

        <dependency>
            <groupId>com.company.project1</groupId>
            <artifactId>project1-war</artifactId>
            <version>${project.version}</version>
            <classifier>classes</classifier>
            <scope>test</scope>
        </dependency>

         <dependency>
            <groupId>com.company.project2</groupId>
            <artifactId>project2-war</artifactId>
            <version>${project.version}</version>
            <classifier>classes</classifier>
            <scope>test</scope>
        </dependency>

In my spring boot configuration i want to import the web-context.xml from project1-war not the one of project2-war like this:

        @ImportResource(locations = { "classpath*:**/project1-war-1.0-classes/web-context.xml" })

but this is not working

Gogo
  • 292
  • 8
  • 19

2 Answers2

0

Try something like this

@ImportResource(value = {
        "classpath:web-context.xml",
        "classpath:fuu/baz/file2.xml"
})

Reference: https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/context/annotation/ImportResource.html#locations--

Vy Do
  • 46,709
  • 59
  • 215
  • 313
  • This link may be useful https://stackoverflow.com/questions/15004674/spring-3-importresource-with-multiple-files – Vy Do Feb 16 '18 at 10:54
  • if i use "classpath:web-context.xml" directly i have duplication error, also i have updated the post – Gogo Feb 16 '18 at 10:59
  • the problem is not the tag value or locations – Gogo Feb 16 '18 at 11:00
  • The first, by some way some how, you must make 2 file `web-context.xml` become different things by its file name or its path. Then, you open directory what generated after build, get path of XML file. – Vy Do Feb 16 '18 at 11:02
  • Uh oh, so simple, don't make it complicated. Since file `web-context.xml` is static content, copy and paste it to a brand new file, then read it manually. – Vy Do Feb 16 '18 at 11:06
0

i think the simplist solution is to rename one of the two files then use:

  @ImportResource(value = {
    "classpath:web-context1.xml",
   })
Gogo
  • 292
  • 8
  • 19