WAS v8.5 > Administer applications and their environment > Administer the Liberty profile > Administer the Liberty profile manually > Use includes, variables, and Ref tags in configuration files

Use includes in configuration files

We can keep all your configuration in a single server.xml file, or we can use include elements to consolidate configurations from separate files to create the structure most useful to you. It can be easier to maintain a complex configuration by splitting it across a set of files. For example:


Example

This is the syntax for including a configuration file. We can set the optional attribute as true to skip the include file when it cannot be found :

...or...

The following list shows the possible locations; they are searched in the order shown.

  1. in a location specified relative to the parent file
  2. in the shared configuration directory
  3. in a location specified as an absolute path
  4. on a web server

To ensure that your include configuration behaves predictably, you need to be aware of the following processing rules for included configuration files:

In the following example, the primary server configuration file server.xml includes the contents of the blogDS.xml configuration file, which is located in the shared configuration directory. The blogDS.xml file contains a data source definition. This definition has been put in a separate configuration file so that it can be included in several different server.xml files, and thereby used across multiple server instances.

Here is example code from server.xml:

server   < featureManager>
    <feature>servlet-3.0</feature>     <feature>jdbc-4.0</feature>   </featureManager>   < application id="blog" location="blog.war" name="blog" type="war"/>   < include optional="true" location="${shared.config.dir}/blogDS.xml"/> </server> 

Here is the example code from the blogDS.xml file:

server   <dataSource id="blogDS" jndiName="jdbc/blogDS" jdbcDriverRef="derbyEmbedded">     <properties createDatabase="create" databaseName="C:/liberty/basics/derby/data/blogDB" />   </dataSource>   <jdbcDriver/>     < library>
      < fileset dir="C:/liberty/basics/derby" includes="derby.jar" />     </library>   </jdbcDriver> </server> 


Parent topic: Use includes, variables, and Ref tags in configuration files


Related concepts:
Liberty profile: Server configuration


Reference:
Liberty profile: Directory locations and properties
Liberty profile: Configuration elements in server.xml