0

How can i represent the following code snippet in java, my project is using Spring4 and i need to convert the same. Any help would be much appreciated. Thanks in advance!

<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
  <property name="environment">
     <props>
        <prop key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop>
        <prop key="java.naming.provider.url">t3://localhost:7001</prop>
     </props>
  </property>

1 Answer 1

1

Here's the equivalent Java config. Add it to your @Configuration class:

@Bean
public JndiTemplate jndiTemplate() {
    Properties props = new Properties();
    props.setProperty(InitialContext.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
    props.setProperty(InitialContext.PROVIDER_URL, "t3://localhost:7001");
    return new JndiTemplate(props);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.