How to set @Required field in Spring without using the application-context.xml file? -
i using spring-boot , trying set required properties (i.e. properties @required tag) of implemented service without using application-context.xml file. in application-context.xml file service looks this:
<bean class="services.impl.myserviceimpl"> <property name="property" value="value" /> </bean>
i guess properties looks in java:
protected properties buildmyserviceimplproperties() { properties myserviceimplproperties = new properties(); myserviceimplproperties.setproperty("property", "value"); homecoming myserviceimplproperties; }
edit: service class myservice define follows:
package services; public interface myservice {}
and implementation is:
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; } }
not sure if understand question, if you're wanting create bean in java config, need this:
@bean public myservice(){ myservice service = new myserviceimpl(); service.setproperty("property", "value"); homecoming service; }
spring-mvc spring-boot spring-java-config
No comments:
Post a Comment