Announcement Announcement Module
Collapse
No announcement yet.
@Autowired and services in a jar Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • @Autowired and services in a jar

    Hi,

    I've created 2 projects, the first one is my core. It has the following packages:
    -core.controller
    -core.service
    -core.dao
    -core.entity
    All the above classes were packaged in a jar.... core.jar

    The second project has the code to expose my controller as rest:
    This project uses core.jar
    -web.rest

    ....
    Controller

    @Component(value = "testController")
    public class TestControllerImpl implements TestController{
    ....
    Rest

    @Component
    @Path("/test")
    @Scope("request")
    public class TestResourceRest implements TestResource {

    @Autowired
    private TestController testController;
    ....


    The problems is that I'm getting the following error when I try to access my resource localhost:8080/myproject/test

    No matching bean of type [core.controller.TestController] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}

    What am I doing wrong?

    Thanks in advance!

  • #2
    Adding more information...

    If I copy and paste the .class files (project core) inside my web project "rest" rest\WEB-INF\classes, the tag @Autowired works

    so strange for me..

    Comment


    • #3
      Solved!

      I just selected "Add directory entries" when building the jar using eclipse.

      Comment


      • #4
        Thank you rafoli. Your solution works fine for me too.
        Thanks again for posting it.

        Comment


        • #5
          dm, im at NetBeans

          Comment

          Working...
          X