0

I have Spring Rest controller[HomeController] and it's working fine as individual war. I converted this Rest controller[HomeController] into Jar and added into another web project[TestWeb] under lib folder. I am trying to call my Rest controller[HomeController] from web project[TestWeb]. But it couldn't find the request mapping and throws 404. In my TestWeb project i have <context:component-scan base-package="com.test.home.controller" /> And i tried to mapping directly using below code, but getting the same error <context:component-scan base-package="com.test.home.controller.HomeController" />

Can you please help me if i missed anything?.

Thanks Saravanan

  • 2
    Please, attach some of your configuration code to the question. Probably your component scan is unable to find controller bean, and you should point to it explicitly. – Nikolai Shevchenko Sep 26 '18 at 15:54
  • Can you put dummy code for your SpringApplication class – Yogi Sep 26 '18 at 16:58

1 Answers1

0

You'll need to import the jar configuration in your TestWeb configuration. Basically, Test Web container doesn't know anything about your controller since it's spring context is different than the TestWeb context.

See How to import spring-config.xml of one project into spring-config.xml of another project? for details.

cosmos
  • 2,143
  • 2
  • 17
  • 27
  • Yes this link helped me to fix my issue, thank you for your help. The issue was i had only class file in my Jar. Now i added xml along with class file into my jar. Then added "". Now everything working as expected. – user7734733 Sep 27 '18 at 13:54