Reputation: 57212
I wrote my own custom namespace for a Spring based project I'm working on. The project is built with maven, and I'd like to put my xsd files in the resources directory. The problem is the spring.schemas directory requires me to define where I put my xsd file. In my dev environment it will be resources/schemas/myschema.xsd. But, when I compile, the contents of the resources get copied to target, not the target directory itself. So in the compiled code, I end up with target/schemas/myschema.xsd. Should my spring.schemas file reference resources/schemas/myschema.xsd? Or just schemas/xsd?
thanks,
Jeff
Upvotes: 1
Views: 975
Reputation: 35848
When creating a custom namespace for Spring the spring.schemas file should be located in META-INF with an entry like this:
http://www.springframework.org/schema/context/spring-context-2.5.xsd=org/springframework/context/config/spring-context-2.5.xsd
Your custom schema should be then in src/main/resources/org/springframework/context/config/ to be added in the classpath of the project.
Any good IDE should understand src/main/resources/ as a source code folder and read the schema just well.
NOTE: I pulled this example from the spring-core.jar, just examine it yourself
Upvotes: 1
Reputation: 4061
It should only point to schemas/myschema.xsd
target/resources will end up in your classpath so you can safely reference everything there.
Upvotes: 1
Reputation: 84078
You can define a linked location in Eclipse. By using a variable to define your workspace root and then creating a linked folder you maintain some measure of portability.
Right-click on the project, select new->Folder
call the folder "schemas", click Advanced>>, select Link to folder in the file system
Select Variables... and pick the WORKSPACE_ROOT variable
Add the relative path to your schemas folder, e.g. [project name]/src/main/resources/schemas
When you finish you'll have a new schemas folder with a little arrow in the corner showing it is linked. You may find you need to force refreshes to get new files to be reflected in the linked location.
Upvotes: 0