Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow default values to be specified for System properties in ResourceEditor [SPR-4622] #9299

Closed
spring-projects-issues opened this issue Mar 24, 2008 · 4 comments
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Dave Syer opened SPR-4622 and commented

Allow default values to be specified for System properties in ResourceEditor. It is really nice that ResourceEditor replaces placeholders with System properties, but it isn't helpful that it ignores (logging at warning level) missing values. It would be useful to specify a default, e.g.

<property name="location" value="classpath:application-${environment:test}.properties"/>
would evaluate to "classpath:application-test.properties" by default, and can be overridden by a System property.


Affects: 2.5.2

@spring-projects-issues
Copy link
Collaborator Author

Dave Syer commented

I have a workaround, by the way, but it isn't pretty. I use this (and make PropertyPlaceholderConfigurers depend on it):

<bean id="environment" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
	<property name="targetClass" value="java.lang.System" />
	<property name="targetMethod" value="setProperty" />
	<property name="arguments">
		<list>
			<value>environment</value>
			<bean class="java.lang.System" factory-method="getProperty">
				<constructor-arg>
					<value>environment</value>
				</constructor-arg>
				<!-- The default value of the environment property -->
				<constructor-arg>
					<value>hsql</value>
				</constructor-arg>
			</bean>
		</list>
	</property>
</bean>

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Apr 21, 2008

Dave Syer commented

#5914 was a similar idea, but that was rejected on the grounds that systen properties are global and shouldn't be manipulated by a Spring application. I think that's reasonable, but we should be able provide a default value for a system property (only set it if it isn't set already). Turning the above XML into a factory bean would be easy and generally pretty useful (myabe even in util: namespace).

@spring-projects-issues
Copy link
Collaborator Author

Rossen Stoyanchev commented

This issue has been resolved through a selective bulk update, as part of a larger effort to better manage unresolved issues. To qualify for the update, the issue was either created before Spring 3.0 or affects a version older than Spring 3.0 and is not a bug.

There is a good chance the request was made obsolete, or at least partly outdated, by changes in later versions of Spring including deprecations. It is also possible it didn't get enough traction or we didn't have enough time to address it. One way or another, we didn't get to it.

If you believe the issue, or some aspects of it, are still relevant and worth pursuing at present you may re-open this issue or create a new one with a more up-to-date description.

We thank you for your contributions and encourage you to become familiar with the current process of managing Spring Framework JIRA issues that has been in use for over a year.

@spring-projects-issues
Copy link
Collaborator Author

Dave Syer commented

This was fixed in Spring 3.0.

@spring-projects-issues spring-projects-issues added type: enhancement A general enhancement in: core Issues in core modules (aop, beans, core, context, expression) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 3.0 GA milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant