0

I am working on a project in Spring, which consists of some small project and dependencies. Here's the simple hierarchy of the parent project:

  • A (a war, the rest web services that will be exposed)
  • B (another war, which will also be exposed)
  • C (jar dependecies for A and B)
  • D (jar dependencies for A and B)

Here's a snippet of my context.xml

<context:component-scan
        base-package="com.mycompany.project.C, com.mycompany.project.D,
        com.mycompany.project.A"/>

<context:property-placeholder location="classpath:application.properties"/>

<mvc:default-servlet-handler/>
<mvc:annotation-driven/>

Everytime I deployed project A, I see in the log that spring is also scanning @Controller and @Service from project B. My question is how can it happen? Is my xml configuration wrong? Please advice.

*I've searched for similar question but can't find any. If you find one, please let me know, maybe I wasn't searching thouroughly.

Thanks

Silly Sally
  • 1,027
  • 2
  • 10
  • 15
  • 1
    I don't understand. Why are the classes of project B, which is a separate war from A, in A.war? – JB Nizet Jan 13 '17 at 08:18
  • the classes of project B is not in project A. it's different project (but one parent project, because B also need jar C and jar D). I dont know why spring mix it up – Silly Sally Jan 13 '17 at 09:08
  • 1
    Then how could spring scan these classes, if they're not in A.war? – JB Nizet Jan 13 '17 at 09:11
  • 1
    How do you deploy? What I noticed in dev environments, is that the safer way to deploy is to restart the servlet container. When you do that, it restarts all the registered web apps, not only the one you are working on. Could the messages about project B controller and services come from the start or B? – Serge Ballesta Jan 13 '17 at 09:44
  • @JBNizet that's what I'm asking – Silly Sally Jan 16 '17 at 10:46
  • @SergeBallesta yes, I deployed in dev. yes, maybe that's the case. i'll try and report back the result. thank you – Silly Sally Jan 16 '17 at 10:51
  • 1
    @SillySally Spring isn't the one building your project and generating the war file. If B ends up in A.war, then you need to fix your dependencies or your build. It's still unclear if the B classes or jar are in A.war or not. Clarify your question, and provide the necessary details: structire of the war, build file. – JB Nizet Jan 16 '17 at 21:47
  • @JBNizet hi all, apparently, it's true. The problem is not with Spring. It probably never is. The problem is my weblogic. it still have the war from the other project so it always loads when I tried to deploy another project, even though both project is unrelated – Silly Sally Jan 18 '17 at 11:31
  • @SergeBallesta thank you – Silly Sally Jan 18 '17 at 11:31

0 Answers0