简体   繁体   中英

Custom entities do not load within a Spring Cloud Dataflow Server

Once I @EnableDataFlowServer my SpringBoot application, my own custom entities do not load. (I get the 'type not managed' exception which occurs when JPA isn't finding your entities).

These entities are found within another Spring module that I import, like

@Import({MyDomainsModule.class})

I'm using 2.0.0.m2 of Spring Cloud DataFlow.

Some debugging I've done:

If I add this to my Spring Boot application main class:

@EntityScan({
"com.company.mydomain.entities"
})

Then my entities start to load as usual, but then Spring DataFlow breaks. For example, any time I try to load the UI, I'll get:

 |ne.jdbc.spi.SqlExceptionHelper|  Table 'dataflow.appregistration' doesn't exist 

That makes me thinking by simply adding the EntityScan, I broke some naming strategy since the actual name of the table is of course app_registration

I think this is mostly a 'how do I do multiple locations of JPA-based code in one project', rather than a Spring Cloud DataFlow question. But knowing the fix might require a better understanding of how SCDF. I've checked out the project and reading up both Spring Boot and how SCDF configures itself.

Any help is greatly appreciated!

I had a bad strategy coming in from one of my properties, overriding what SCDF added this to my application.properties.

So to be explicit, I set this in my properties:

spring.jpa.hibernate.naming.physical-strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
spring.jpa.hibernate.naming.implicit-strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy

And then my SpringBoot application looks like

@SpringBootApplication(exclude = LocalDataFlowServerAutoConfiguration.class)
@Import({MyDomainModule.class})
@EnableDataFlowServer

// EnableDataFlowServer has an EntityScan, which causes ours to not be picked up!
// Look in DataFlowControllerAutoConfiguration for more information
@EntityScan({
"com.company.mydomain.entities"
})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM