求教大神,spring找不到类文件,该怎么解决
求教大神,spring找不到类文件

下面是log类
这是我的xml
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource" >
<!--变量通过依赖注入来完成-->
<property name="basename">
<value>com.sun.xml.internal.bind.Messages</value>
</property>
</bean>
<bean id="HelloWorld" class="com.gc.action.HelloWorld">
</bean>
<bean id="date" class="java.util.Date"></bean>
<bean id="log" class="com.gc.action.Log"></bean>
<bean id="listener" class="com.gc.action.LogListener"></bean>
</beans>
------解决思路----------------------
你看下部署在WEB中的项目里有没这个类
------解决思路----------------------
很有可能是冲突了 这个类系统存在 你把bean 的id换一下 然后 在获取
------解决思路----------------------

编译就出错了,自己看看jar包版本或者JDK版本或者开发工具版本
换几次试试。
下面是log类
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
/**
* Created by Administrator on 2015/3/18.
*/
public class Log implements ApplicationContextAware {
private ApplicationContext applicationContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
public int log(String log){
LogEvent event=new LogEvent(log);
this.applicationContext.publishEvent(event);
return 0;
}
}
import com.gc.action.Log;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
/**
* Created by Administrator on 2015/3/18.
*/
public class TestHelloWorld {
public static void main(String[] args) throws InstantiationException,IllegalAccessException
,ClassNotFoundException{
/*ApplicationContext actx=new FileSystemXmlApplicationContext("config.xml");
HelloWorld helloWorld=(HelloWorld)actx.getBean("HelloWorld");
System.out.println(helloWorld.getDate()+""+helloWorld.getMsg());
// Hello hello=(Hello)actx.getBean("HelloWorld");
//System.out.println(hello.doSalutation());*/
ApplicationContext actx= (ApplicationContext) new FileSystemXmlApplicationContext("config.xml");
Log log=(Log)actx.getBean("log");
log.log("gf");
}
}
这是我的xml
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource" >
<!--变量通过依赖注入来完成-->
<property name="basename">
<value>com.sun.xml.internal.bind.Messages</value>
</property>
</bean>
<bean id="HelloWorld" class="com.gc.action.HelloWorld">
</bean>
<bean id="date" class="java.util.Date"></bean>
<bean id="log" class="com.gc.action.Log"></bean>
<bean id="listener" class="com.gc.action.LogListener"></bean>
</beans>
------解决思路----------------------
你看下部署在WEB中的项目里有没这个类
------解决思路----------------------
很有可能是冲突了 这个类系统存在 你把bean 的id换一下 然后 在获取
------解决思路----------------------
编译就出错了,自己看看jar包版本或者JDK版本或者开发工具版本
换几次试试。