Search code examples
javaspringjakarta-eespring-roo

Spring roo entity dependency


I'm working with Spring-Roo.

Is it possible to add field reference from a dependent package? I've added dependency at the begging of the script,

dependency add --groupId com.testroo.platform --artifactId platform --version 0.1.0.BUILD-SNAPSHOT

then I execute this while adding a jpa entity

field reference --fieldName city --type ~.domain.City --notNull

yet it complains with following.

The specified target '--type' does not exist or can not be found. Please create
this type first. 

I thought spring-roo is smart enough to resolve it from dependency. Am I missing anything here? cheers.


Solution

  • When working with Spring roo and create a new project, you declare a top-level package name (assume com.foo entered) as a first step. ~ sign is used to refer to this package name later on.

    So, in your case if you give the ~.domain.City as a parameter to the type argument, roo will look for it in com.foo.domain.City since ~ sign replaces top level package.

    Short answer: If you want to add a field reference from a dependent package, give the full name of the class.