Hi friends i am developing a maven based spring boot project project , this project is multiple module form one module is Main module and second module is Service Module. I have one controller in Main module and one service in Serivce module
Controller
package com.aquevix.controller; import com.aquevix.common.MyService; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import javax.inject.Inject; /** * Created by mohdqasim on 11/9/15. */ @RestController @RequestMapping("/api") public class MyController { @Inject MyService myService; @Inject BookRepository bookRepository; @RequestMapping(value = "/data" , method = RequestMethod.GET) public String getData(){ return myService.getData(); } } Service
package com.aquevix.common; import org.springframework.stereotype.Service; /** * Created by mohdqasim on 11/9/15. */ @Service public class MyService { public String getData(){ return "hello qasim"; } } In maven multiple modules this scenerio is working fine but i have also one repository in the form of interface in service module.
package com.aquevix.common; import org.springframework.data.jpa.repository.*; /** * Spring Data JPA repository for the Book entity. */ public interface BookRepository extends JpaRepository<Book,Long> { } So when i execute main class from Main module my project works fine without bookrepository in service module( or present in Main module) but if i put bookrepository in Service module then MyController could not instantiate due dependency injection failure of bookRepository in MyController. Can anyone help me how to to avoid this failure i put any interface in Service module which is being injected into Main module