Java类:
package com.org.spring;
public class Restuarent {
public void greatingMessage() {
System.out.println("Welcome..");
}
}
Java Class For Test Spring:
public class TestSpringPro {
@SuppressWarnings("resource")
public static void main(String[] args) {
try {
ApplicationContext context =
new ClassPathXmlApplicationContext("springConfig.xml");
Restuarent restObj = (Restuarent) context.getBean("restuarentBean");
restObj.greatingMessage();
} catch(Exception e) {
e.printStackTrace();
e.getMessage();
}
}
}
XML: bean Configuration
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="restuarentBean" class="com.org.spring.Restuarent">
</bean>
</beans>
我是新的java,因为我有点困惑,而调试这个简单的spring程序在结束时,我要去"Thread.exit()行:不可用",但简单地运行没有错误,为什么请让我知道。我知道这可能很简单,但是提前感谢
Window->Preferences, Java->Installed JRE's,点击我的JRE并点击编辑。现在单击Add External Jar,转到您的java路径"C:Program FilesJavajdk1.8.0_60"并找到src.zip并添加此在此之后,我验证了它的工作