title: spring 3.1 setting profile
body: <p>I want to start using profile in Spring 3.1 and i found a problem.</p>
  
  <p>In my hibernate xml file i've set</p>
  
  <pre><code>&lt;beans profile="test"&gt;
  
      &lt;context:property-placeholder location="/WEB-INF/springtest.properties" /&gt;
  
  
  &lt;/beans&gt;
  
  &lt;beans profile="production"&gt;
  
      &lt;context:property-placeholder location="/WEB-INF/spring.properties" /&gt;
  
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>And in web.xml i've set:</p>
  
  <pre><code>&lt;servlet&gt;
      &lt;servlet-name&gt;appServlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;/WEB-INF/spring/appServlet/servlet-context.xml&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;spring.profiles.active&lt;/param-name&gt;
          &lt;param-value&gt;production&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  </code></pre>
  
  <p>but when i'm trying to run application i have issue, that spring doesn't see variables from <code>spring.properties</code> file.</p>
  
  <p>Should i set something else ?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>hibernate file looks like this:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans  xmlns="http://www.springframework.org/schema/beans"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:p="http://www.springframework.org/schema/p" 
          xmlns:tx="http://www.springframework.org/schema/tx"
          xmlns:context="http://www.springframework.org/schema/context"
          xsi:schemaLocation="
              http://www.springframework.org/schema/beans 
              http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
              http://www.springframework.org/schema/tx 
              http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
              http://www.springframework.org/schema/context
              http://www.springframework.org/schema/context/spring-context-3.1.xsd
              "&gt;
  
      &lt;context:property-placeholder location="/WEB-INF/spring.properties" /&gt;
  
  
      &lt;!-- Enable annotation style of managing transactions --&gt;
      &lt;tx:annotation-driven transaction-manager="transactionManager" /&gt;
      &lt;!-- &lt;tx:annotation-driven/&gt; --&gt;
  
      &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
                   p:dataSource-ref="dataSource"
                   p:configLocation="${hibernate.config}"
                   p:packagesToScan="com.app.search"&gt;
          &lt;property name="annotatedClasses"&gt;
              &lt;list&gt;
                  &lt;value&gt;com.app.search.domain.UsersEntity&lt;/value&gt;
                  &lt;value&gt;com.app.search.domain.CategoryEntity&lt;/value&gt;
                  &lt;value&gt;com.app.search.domain.GroupEntity&lt;/value&gt;
                  &lt;value&gt;com.app.search.domain.PlacesEntity&lt;/value&gt;
                  &lt;value&gt;com.app.search.domain.ProvincesEntity&lt;/value&gt;
                  &lt;value&gt;com.app.search.domain.PageAreaEntity&lt;/value&gt;
                  &lt;value&gt;com.app.search.domain.PageConfigurationEntity&lt;/value&gt;
                  &lt;value&gt;com.app.search.domain.PageTemplateEntity&lt;/value&gt;
                  &lt;value&gt;com.app.search.domain.PageTypeEntity&lt;/value&gt;
                  &lt;value&gt;com.app.search.domain.PageModuleEntity&lt;/value&gt;
                  &lt;value&gt;com.app.search.domain.PageModuleAreaConfigurationEntity&lt;/value&gt;
                  &lt;value&gt;com.app.search.domain.PageModuleConfigurationEntity&lt;/value&gt;
                  &lt;value&gt;com.app.search.domain.PageFacetEntity&lt;/value&gt;
                  &lt;value&gt;com.app.search.domain.PageFacetAreaEntity&lt;/value&gt;
                  &lt;value&gt;com.app.search.domain.PageTemplateFacetEntity&lt;/value&gt;
              &lt;/list&gt;
          &lt;/property&gt;
          &lt;property name="hibernateProperties"&gt;
              &lt;props&gt;
                  &lt;prop key="hibernate.connection.url"&gt;jdbc:mysql://localhost/Search&lt;/prop&gt;
                  &lt;prop key="hibernate.connection.driver_class"&gt;com.mysql.jdbc.Driver&lt;/prop&gt;
                  &lt;prop key="hibernate.connection.username"&gt;root&lt;/prop&gt;
                  &lt;prop key="hibernate.connection.password"&gt;&lt;/prop&gt;
              &lt;/props&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
  
      &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
          &lt;property name="driverClassName" value="${app.jdbc.driverClassName}" /&gt;
          &lt;property name="url" value="${search.jdbc.url}" /&gt;
          &lt;property name="username" value="${search.jdbc.user}" /&gt;
          &lt;property name="password" value="${search.jdbc.password}" /&gt;
      &lt;/bean&gt;
  
  
      &lt;!-- Declare a transaction manager--&gt;
      &lt;bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager" p:sessionFactory-ref="sessionFactory"&gt;
          &lt;qualifier value="transactionManager"/&gt;
      &lt;/bean&gt;
  
      &lt;beans profile="test"&gt;
  
          &lt;context:property-placeholder location="/WEB-INF/springtest.properties" /&gt;
  
  
      &lt;/beans&gt;
  
      &lt;beans profile="production"&gt;
  
          &lt;context:property-placeholder location="/WEB-INF/spring.properties" /&gt;
  
      &lt;/beans&gt;
  
  
  
  &lt;/beans&gt;
  </code></pre>