1、How do I configure a bean like this using Spring
DSL
?
<bean id="mailSession" class="javax.mail.Session" factory-method="getInstance">
<constructor-arg>
<props>
<prop key="mail.smtp.auth">true</prop>
</props>
</constructor-arg>
<constructor-arg ref="smtpAuthenticator" />
</bean>
2、
To answer my own question it should look like this:
beans = {
def props = new Properties()
props.setProperty('mail.smtp.auth', 'true')
mailSession(javax.mail.Session, props, ref('smtpAuthenticator')) { bean ->
bean.factoryMethod = 'getInstance'
}
...
}
Note that using Properties makes the code less tidy than if the
property accepted a Map.
分享到:
相关推荐
Siva Prasad Reddy Spring is the most popular Java-based framework for building enterprise ...applications quickly and easily, and the inner workings of Spring Boot using easy-to-follow examples.
4. Working with Spring Boot 5. Learning about Spring Boot Features 6. Moving to Production 7. Advanced Topics II. Getting Started 8. Introducing Spring Boot 9. System Requirements 9.1. Servlet ...
// Configure the bean definition reader with this context's resource loading environment. beanDefinitionReader.setEnvironment(this.getEnvironment()); beanDefinitionReader.setResourceLoader(this); ...
The SqlSessionFactoryBean provided by MyBatis-Spring simplifies the process of setting up the factory, allowing us to easily configure it with a DataSource. 2. **DataSource**: A DataSource is ...
Spring Boot动态创建Bean示例代码详解 Spring Boot框架中提供了多种方式来创建Bean,今天我们就来学习其中的一种,即动态创建Bean。动态创建Bean可以根据特定的条件来决定是否创建Bean,这在实际开发中非常有用。 ...
Spring is the most popular Java-based framework for building enterprise applications....applications quickly and easily, and the inner workings of Spring Boot using easy-to-follow examples.
Beginning Robotics with Raspberry Pi and Arduino_Using Python and OpenCV-Apress(2018) Robotics does not have to be difficult. In this book, I introduce you to the field of robotics. The journey will ...
How to configure DCM UDS with the DEXT Editor.pdf
As Spring is a very flexible and customizable framework, there are usually multiple ways to configure the application. Although it is a good thing to have multiple options, it can be overwhelming to ...
The author, a senior solutions architect and Principal Technical instructor with Pivotal, the company behind the Spring Framework, shares his experience, insights and first-hand knowledge about how ...
s4/hana cloud Using Configure Your Solution and SSCUIs
This module provides a new dialect called org.thymeleaf.extras.springsecurity3.dialect.SpringSecurityDialect or org.thymeleaf.extras.springsecurity4.dialect.SpringSecurityDialect (depending on the ...
Spring MVC is a lightweight application framework that comes with a great configuration by default. Being part of the Spring Framework, it naturally extended and supported it with an amazing set of ...
通过右键点击文件,选择"Open With" -> "Spring Bean Editor",可以看到一个图形化的界面,可以直观地管理Bean和它们的属性。 接下来,我们引入Spring的MVC框架进行Web开发。在`web.xml`中配置DispatcherServlet,...
Mastering Spring Cloud_Build self-healing, microservices-based, distributed systems using Spring Cloud-Packt Publishing(2018) Developing, deploying, and operating cloud applications should be as easy...
"的输出,这表明Spring成功地实例化并注入了Bean。 以上就是在Eclipse中进行Spring基本配置的详细步骤。这只是Spring框架的冰山一角,更深入的应用包括事务管理、AOP、数据访问等,都需要进一步学习和实践。对于...
4. **创建Jersey Application子类**:在`MyApplication`类中,你需要注册Spring的ContextResolver,以便Jersey能从Spring容器中查找bean: ```java public class MyApplication extends ResourceConfig { public ...
The book progressively teaches you to configure the Spring development environment, architecture, controllers, libraries, and more before moving on to developing a full web application. It begins with...
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate"> </bean> <!-- Message Listener --> <bean id="messageListener" class="com.example.MyMessageListener" /> <!-- ...