尝试自动装配时获取空指针。
创建 Web 应用程序并使用以下 Web 服务:
WebServiceEndpoint.java
@WebService
@Component
public class ChannelMapWebServiceEndpoint {
@Autowired
ChannelMapWebService webservice;
public ChannelMapInfo4[] getMaps() throws RemoteException {
return this.webservice.getMaps();
}
}
ChannelMapsebserviceImpl.java
@Service
public class ChannelMapWebServiceImpl implements ChannelMapWebService {
public ChannelMapInfo4[] getMaps() throws RemoteException {
System.out.println("hi");
}
}
应用程序上下文.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:annotation-config />
<context:component-scan base-package="ccad" />
<context:component-scan base-package="channelmapwebservice" />
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>/WEB-INF/jdbc.properties</value>
</property>
</bean>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${jdbc.driverClassName}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</bean>
</beans>
尝试通过 SoapUI 连接时,我将自动装配的对象 web 服务设为空。