C. Ross
C. Ross

Reputation: 31848

Is it possible to have a dynamic resource path for import?

I have a Spring.NET program with a configuration file. To smooth the transition from test to prod I'd like to have an environment variable that gives the path to a shared config file, and use that to import a resource, however it appears the <import resource="path"/> is not being resolved. For example if I try to load the file <import resource="\\server\share\${computername}\SpringConfig.xml"/> I get a file not found exception as below:

System.Configuration.ConfigurationErrorsException: Error creating context 'spring.root': file [\server\share\${computername}\SpringConfig.xml] cannot be resolved to local file path - resource does not use 'file:' protocol. ---> Spring.Objects.Factory.ObjectDefinitionStoreException: IOException parsing XML document from file [\server\share\${computername}\SpringConfig.xml] ---> System.IO.FileNotFoundException: file [\server\share\${computername}\SpringConfig.xml] cannot be resolved to local file path - resource does not use 'file:' protocol.

Is there a way I can have a dynamic import path in Spring.NET, preferably without writing code?

Upvotes: 3

Views: 2934

Answers (2)

bbaia
bbaia

Reputation: 1183

You can do that anyway with some extra code:

Upvotes: 5

bbaia
bbaia

Reputation: 1183

I don't think we can do that with the current version. Latest Java version supports it, so we can expect this feature in a future version (Using variables environnement by default)

Upvotes: 2

Related Questions