I would like to map my ldapserver port setting to a property in my property file.
But when i use ${ldapserverport} than i get the error:
“The value ‘${ldapserverport}’ of
attribute ‘port’ on element
‘ldap-server’ is not valid with
respect to its type,
‘positiveInteger’.”
Is there anyway to cast this property?
The other properties are working perfect.
my code:
<ldap-server id="ldapServer" url="${ldapserverurl}"
port="${ldapserverport}"
manager-dn="${ldapserveruser}"
root="${ldapserverroot}"
manager-password="${ldapserverpassword}"/>
This is a shortcoming of the “custom namespace” approach used by some Spring config styles. While it allows configurations to be expressed very concisely, it’s also highly specific, and doesn’t automatically allow any of the generic substitution logic used by
<bean>-style definitions, including property placeholders.If the schema author has put in a hard-wired requirement for a given attribute to be an integer, then there’s no getting around it – the author of the schema, and the code that parses it, would have to add explicit support for placeholders. In this case, they haven’t.
So if you want to use placeholders, you’ll have to “explode” the
<ldap-server>shortcut definition into the graph of underlying<bean>definitions. This isn’t always easy, since the docs have to explain what beans are actually defined by<ldap-server>.