java - import JPA Model from gradle sub-project in Spring -


in android project, want use shared model library rest server(jpa)
project structure:

├── android │   └ ... │ ├── model │   ├── build.gradle │   └── src │       └── com │           └── model                            // error @ runtime │               └── customer.java ├── server │   ├── build.gradle │   └── src │       └── com │           └── server │                ├── application.java │                ├── customercontroller.java │                ├── customerrepository.java │                └── model                       // works fine │                    └── customer.java ├── build.gradle 

i using gradle sub-projects manage dependency works fine @ compile time. when run application, spring can't resolve jpa annotations. when move model class server project, works fine.

exception in thread "main" org.springframework.beans.factory.beancreationexception: error creating bean name 'requestmappinghandlermapping' defined in class path resource [...] instantiation of bean failed; [...]  not managed type: class com.model.customer 

full stacktrace

root build.gradle

buildscript {  ...  }  allprojects {     repositories {         mavencentral()     } }  project(":android") {  ...  }  project(":model") {     apply plugin: "java" }  project(":server") {     apply plugin: "java"      dependencies {         compile project(":model")     } } 

is there solution include jpa models gradle sub-project ?
reason prevent duplicate code between android , server appication

demo-project.zip

you customer entity not found default because not in sub-pacakge of application class. try using @entityscan annotation (see http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-separate-entity-definitions-from-spring-configuration).


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -