DevZer0
DevZer0

Reputation: 13525

requestmapping invalid after configuring entity path

I have a project called models which i import via maven, it consists of Hibernate Entities,

I setup this models project as a dependency on a project that i have configured Spring, it uses spring boot.

if i try to run the project it tells me that Not a managed type:when i reference an entity from the models project. i managed to fix it using the following annotations

@EnableJpaRepositories({"com.rajeeda.coopmis.models.*", "com.rajeeda.coopmis.web.*"})
@ComponentScan(basePackages = { "com.rajeeda.coopmis.web.*" , "com.rajeeda.coopmis.models.*"})
@EntityScan({"com.rajeeda.coopmis.models.*", "com.rajeeda.coopmis.web.*"})

```

once i setup the path to models then spring boots up fine, but none of the @RequestMapings from spring is being reached. as i get a 404 screen, i tried seven specifying path using

server.servlet.contextPath=/mainstay`

still no luck, is there a way i can explicitly provide the path of controllers?

if i remove the above annotations from the Application class then the end points works but i get the not managed entity error (i test and confirm the controllers are working when i remove the following class

 public interface UserRepository extends CrudRepository<ItUserMaster, Integer> {}

if anyone has faced the same problem please do share. thanks in advance

Upvotes: 1

Views: 44

Answers (1)

user10639668
user10639668

Reputation:

Not sure this will solve the issue, but you can give it a try.

Let us use basePackages and remove the wildcard like this:

@EnableJpaRepositories(basePackages = {"com.rajeeda.coopmis.models", "com.rajeeda.coopmis.web"})
@ComponentScan(basePackages = { "com.rajeeda.coopmis.web" , "com.rajeeda.coopmis.models"})
@EntityScan(basePackages = {"com.rajeeda.coopmis.models", "com.rajeeda.coopmis.web"})

Upvotes: 1

Related Questions