Posting Spring bean via annotations and xml context

I have the following Spring service:

@Service
public class Worker {

    @Autowired
    private MyExecutorService executor;

    @Autowired
    private IRun run;

    private Integer startingPoint;

    // Remainder omitted

}

Now I want to upload the file startingPointvia .properties.

Is it possible to connect Spring service through annotations and xml context at the same time?

Maybe something like this:

<bean id="worker" class="Worker">
    <property name="startingPoint">
        <value>${startingPoint}</value>
    </property>
</bean>

startingPoint It is connected via the xml context file, everything else becomes automatically connected.

+3
source share
1 answer

Yes! This is certainly possible, and it is a good way to go if you cannot get around using a little XML. Just leave all your annotated fields unspecified and they will be automatically entered.

, , , Integer. Spring XML.

+3

All Articles