【发布时间】:2014-10-14 19:58:19
【问题描述】:
我正在使用 Spring-Boot,并且我正在尝试在不使用 application-context.xml 文件的情况下设置已实现服务的必需属性(即带有 @Required 标记的属性)。在我的 application-context.xml 文件中,服务如下所示:
<bean class="services.impl.MyServiceImpl">
<property name="property" value="value" />
</bean>
我猜这些属性在 Java 中看起来像这样:
protected Properties buildMyServiceImplProperties()
{
Properties myServiceImplProperties = new Properties();
myServiceImplProperties.setProperty("property", "value");
return myServiceImplProperties;
}
编辑:服务类 MyService 定义如下:
package services;
public interface MyService {}
而实现是:
package services.impl;
import services.DoctorService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@Transactional
public class MyServiceImpl implements MyService {
private String value;
@Required
public void setProperty(String value) {
this.value = value;
}
}
【问题讨论】:
标签: spring-mvc spring-boot spring-java-config