title: @component spring annotation in wicket project?
body: <p>I am very new to SO,I have working on the task where Load environment configurations and properties  according to the environment like (dev,prod,test),I have been successfully  achieved database configuration on DAO level by using <code>&lt;beans profile="profile.name"&gt;</code>. In front end side I have to get properties file according to the environment so I have the different files. to call that i have tried the below code:</p>
  
  <pre><code>import org.springframework.beans.factory.annotation.Value;
  import org.springframework.stereotype.Component;
  
  
  @Component
  public class PropertiesUtility {
      @Value("${mount.images.webpath}")
      private String imagePath;
  
      public String getImagePath() {
          return imagePath;
      }
  
      public void setImagePath(String imagePath) {
          this.imagePath = imagePath;
      }
  
      @Override
      public String toString() {
          return "PropertiesUtility{" +
                  "imagePath='" + imagePath + '\'' +
                  '}';
      }
  }
  </code></pre>
  
  <p>My context.xml configuration:</p>
  
  <pre><code>&lt;context:annotation-config/&gt;
      &lt;beans profile="dev"&gt;
              &lt;context:property-placeholder  location="classpath:properties/pharmisa_web_conf.properties"
                                             ignore-unresolvable="true" /&gt;
  
          &lt;/beans&gt;
          &lt;beans profile="test"&gt;
              &lt;context:property-placeholder  location="classpath:properties/pharmisa_web_test_conf.properties"
              ignore-unresolvable="true" /&gt;
  
          &lt;/beans&gt;
  </code></pre>
  
  <p><strong>Calling PropertiesUtility:</strong></p>
  
  <pre><code>public class URLUtility {
      @SpringBean //even @Autowired also not working
     static PropertiesUtility propertiesUtility;
      public static String getCompanyLogoUrl(int id) {
          StringBuffer sb = new StringBuffer(getImagePath());
          boolean isEndWithSlash=PharmisaStringUtils.endsWith(getImagePath(),"/");
          if (!isEndWithSlash){
              sb.append("/");
          }
          sb.append(id);
          sb.append("/");
          return sb.toString();
      }
  
      private static final String getImagePath() {
  
          return propertiesUtility.getImagePath().trim();
      }
  
  }
  </code></pre>
  
  <p><strong>SpringJunitTest</strong></p>
  
  <blockquote>
    <p>Test working perfectly</p>
  </blockquote>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @ContextConfiguration(locations = {"classpath:spring/pharmisa_web-context.xml"})
  @ActiveProfiles(profiles = "test")
  public class CompanyServiceImplTest {
  
      @Autowired
      PropertiesUtility propertiUtility;
  
      @Test
      public void testAppProperties() {
          System.out.println(propertiUtility.getImagePath());
      }
  
  }
  </code></pre>
  
  <p>When i tried to inject  PropertiesUtility class in wicket page  .I am not getting the value of the properties. because it is not injected. I have aware of <code>@SpringBean</code> in wicket but even though it is not working.</p>
  
  <p>Is there anyway to get the value any alternative welcomes.</p>
  
  <p>For your further i have followed the link</p>
  
  <p><a href="http://examples.javacodegeeks.com/enterprise-java/spring/load-environment-configurations-and-properties-with-spring-example/" rel="nofollow">http://examples.javacodegeeks.com/enterprise-java/spring/load-environment-configurations-and-properties-with-spring-example/</a></p>