Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question
0

Using @Value with pu.properties file

Hi! I'm developing an application with XAP 11, and currently I'm trying to inject values into my processing unit, using the @Value("${my.property}") annotation. It works for injecting values into my pu.xml file, but it doesn't work for the processing unit. What am I doing wrong?

My pu.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:context="http://www.springframework.org/schema/context"
   xmlns:os-core="http://www.openspaces.org/schema/core"
   xmlns:os-events="http://www.openspaces.org/schema/events"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans.xsd
   http://www.springframework.org/schema/context
   http://www.springframework.org/schema/context/spring-context.xsd
   http://www.openspaces.org/schema/core
   http://www.openspaces.org/schema/9.7/core/openspaces-core.xsd
   http://www.openspaces.org/schema/events
   http://www.openspaces.org/schema/events/openspaces-events.xsd">

    <bean id="propertiesConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>

    <context:annotation-config/>
    <context:component-scan base-package="com.project"/>

    <os-core:giga-space-context/>
    <os-core:annotation-support/>
    <os-events:annotation-support/>

    <os-core:space-proxy id="space" space-name="${my.space}"/>
    <os-core:giga-space id="gigaSpace" space="space"/>
</beans>

Inside my class:

@Polling
@EventDriven
public class Unit {

    @Value("${my.property}")
    private String property;

My pu.properties:

my.space = some-space
my.property = something

asked 2016-05-04 07:42:48 -0500

Tomas gravatar image
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

Can you please try the following as a test or workaround?

  1. Add the @Component annotation to your class 'Unit'
  2. Add to the PropertyPlaceholderConfigurer definition in the pu.xml

    <property name="locations">
      <list>
        <value>/META-INF/spring/pu.properties</value>
      </list>
    </property>
    

Thanks,

Dixson

answered 2016-05-18 16:28:40 -0500

Dixson Huie gravatar image
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2016-05-04 07:42:48 -0500

Seen: 474 times

Last updated: May 18 '16