File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Spring and the fly likes Production code and Development code/settings must different Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Production code and Development code/settings must different" Watch "Production code and Development code/settings must different" New topic

Production code and Development code/settings must different

Charles Roos

Joined: Dec 14, 2012
Posts: 5
My project has a XML file "", that needs to have different content for Production environment and different content when in Development mode. How can i achieve that?

I understand that Java does not have pre-compiler directives (like #ifdef and others). But if Java had such possibility i would do in file "" so:

#ifdef Production Then

decisionIType.(class) =
decisionIType.contentType = application/pdf;charset=UTF-8
decisionIType.stylesheetLocation = file:\\\C:\\ProductionFolder\\xsl\\decisionsIType.xsl


decisionIType.(class) =
decisionIType.contentType = application/pdf;charset=UTF-8
decisionIType.stylesheetLocation = file:\\\C:\\DevelopmentFolder\\xsl\\decisionsIType.xsl


I connect to file "" with a Spring bean automatically so in a xml file (by setting property "basename"="views" which makes connection to ""):

If pre-compiler directives were allowed there, then i perhaps also could there write if-else to determine if to load file "" or "".

My overall goal is to have file "" different when in Production mode and when in Development mode.
What do you suggest?
Bill Gorder

Joined: Mar 07, 2010
Posts: 1632

Use Spring profiles

[How To Ask Questions][Read before you PM me]
It is sorta covered in the JavaRanch Style Guide.
subject: Production code and Development code/settings must different
Similar Threads
Spring "" file field "stylesheetLocation" needs to point outside of project/WAR-file
SimpleFormController - form:form action URL points to formView in stead of the URL
Spring MVC - Url Handling Problem
Problem with UTF-8 Character encoding
problem in ResourceBundleViewResolver