我有这个密码。。。
public static void main(String[] args)
{
ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
}
应用程序上下文.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"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd
http://cxf.apache.org/jaxrs
http://cxf.apache.org/schemas/jaxrs.xsd">
</beans>
代码退出,但JVM从未停止。
有人知道为什么它不停吗?
我还尝试了以下新的Main方法,但它仍在运行。
公共静态void main(String[]参数)
{
ApplicationContext context=新ClassPathXmlApplicationContext(“ApplicationContext.xml”);
(((ConfigurationApplicationContext)上下文).registerShutdownHook();
((ConfigurationApplicationContext)上下文).stop();
System.out.println(“立即退出…”);
}
如果我暂停JVM,它将显示4个线程。
1与TimerThread.run()
带ScheduledThreadPoolExecutor.take()的3