I have two different maven projects in first I am trying to keep two modules one for "repository and entities" and second for the services. The second project is containing only one module with the "controllers". Now I am having many problems first is "Not a managed type" for the entities. Another thing if I keep everything in one module or even in one project with different modules it works flawlessly, however, I am just trying to put the different package in different project and module
The entityscan, enablejparepositries and all others are working, the debug states:
``` name: default persistence provider classname: null classloader: sun.misc.Launcher$AppClassLoader@42a57993 excludeUnlistedClasses: true JTA datasource: null Non JTA datasource: HikariDataSource (null) Transaction type: RESOURCE_LOCAL PU root URL: file:/F:/Software/MavenRepo/com/company/repo/1.0.0/repo-1.0.0.jar Shared Cache Mode: UNSPECIFIED Validation Mode: AUTO Jar files URLs [] Managed classes names [ com.company.sitemap.repo.Page] Mapping files names [] Properties []
However, At the last it states `Caused by: java.lang.IllegalArgumentException: Not a managed type: class com.company.sitemap.repo.Page` and shows error starting the application. Can you please help me out with this?
Here is my Application class file
package com.company.sitemap;
import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.ComponentScan; import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import com.company.sitemap.repo.SitemapRepoConfig; import com.company.sitemap.service.SitemapConfig;
@SpringBootApplication @EnableJpaRepositories(basePackageClasses = { SitemapRepoConfig.class }) @EntityScan(basePackages = {"com.nie.learn.sitemap.repo"}) @ComponentScan(basePackageClasses = { SitemapConfig.class, SitemapRepoConfig.class }) public class Sitemap extends SpringBootServletInitializer {
public static void main(String[] args) {
ConfigurableApplicationContext applicationContext = SpringApplication.run(DronaSitemap.class, args);
for (String name : applicationContext.getBeanDefinitionNames()) {
System.out.println(name);
}
}
}
The entity class resides in different project and module. Let say Project-libs and module module-repo. I am trying to add this as a maven dependency. The entity file is as follows:
package com.company.sitemap.repo;
import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id;
@Entity public class Page { ```
Comment From: snicoll
Thanks for getting in touch, but it feels like this is a question that would be better suited to Stack Overflow. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug.
Comment From: ullashunka
I have already added this question in StackOverflow. However, no one seems to find the workaround so what I put it here. The link is as follows: https://stackoverflow.com/questions/59609835/spring-boot-jpa-with-different-parent-for-entity-and-service
Comment From: ullashunka
By the way just want to ask, why this not qualifies as a bug. Since the same thing is working if resides in a single project and different modules. But the moment extract the packages and put them in the different project and use the classes as jar file it shows error.
Comment From: snicoll
@ullashunka there is nothing that indicates it is a bug. From the conversation in SO and the description it looks like a project setup issue to me. Regardless, you'd get much faster support if you shared an actual sample that folks could run. Right now, people could only guess based on what you've described.