如果没有任何初始化
我是Java的新手。我的Java类下方: -
@WebService
@SOAPBinding(style = SOAPBinding.Style.RPC, use = SOAPBinding.Use.LITERAL)
public class ABC extends AbstractWebService {
protected ClassNameForService classNameForService;
public void init() {
}
@WebMethod
@Path("/test")
@Produces("text/plain")
@GET
/**
*
* @return String
*/
public String test(
@WebParam(partName = "sessionID")
@QueryParam("sessionID") String sessionID
) throws UserNotDefinedException
{
// does something here
}
}
和下面是我的春季配置文件
<bean id=”org.testproject.webservices.ABC class=”org.testproject.webservices.ABC init-method=”init” parent=”org.testproject.webservices.AbstractWebService”>
<property name=classNameForService ref=”org.testproject.service.gb.ClassNameForService/>
</bean>
,所以我们需要init-method =“ init”
在这里?我可以从配置以及从类中删除“ init” 从类中删除是标准练习吗?
I am new to Java. I have below java class:-
@WebService
@SOAPBinding(style = SOAPBinding.Style.RPC, use = SOAPBinding.Use.LITERAL)
public class ABC extends AbstractWebService {
protected ClassNameForService classNameForService;
public void init() {
}
@WebMethod
@Path("/test")
@Produces("text/plain")
@GET
/**
*
* @return String
*/
public String test(
@WebParam(partName = "sessionID")
@QueryParam("sessionID") String sessionID
) throws UserNotDefinedException
{
// does something here
}
}
and below is my spring configuration file
<bean id=”org.testproject.webservices.ABC class=”org.testproject.webservices.ABC init-method=”init” parent=”org.testproject.webservices.AbstractWebService”>
<property name=classNameForService ref=”org.testproject.service.gb.ClassNameForService/>
</bean>
So do we need init-method=”init”
here? Can I remove init-method=”init”
from configuration as well as init method from class, Is it a standard practice?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不必指定初始方法(或为此销毁方法)。我认为值得注意的是,您问您是否是标准练习,我相信标准实践已从XML配置转变为注释驱动的方法,但出于您的问题的目的,在您的问题中,不包括初始方法时不包括初始方法不需要。
init-method
类似于添加@PostContStruct
在注释为bean上注释的方法。You do NOT have to specify an init method (or destroy method for that matter). I think it's worth noting that you ask if it's standard practice, I believe the standard practice has moved away from the XML configuration to an annotation-driven approach but for the purpose of your question, it is standard practice to not include an init method when it is not needed.
The
init-method
is akin to adding a@PostContstruct
annotated method on annotation declared beans.