java -cp 执行class
用java命令执行某个类时,因为用到了一些依赖包,所以需要把lib以及classes中的内容导入。
Java -cp lib/*:webapps/ROOT/WEB-INF/lib/*:webapps/ROOT/WEB-INF/classes com.govoid.task.admin.OrderPriceExportTask
异常如下
Exception in thread "main" java.lang.NoClassDefFoundError: org.springframework.beans.FatalBeanException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCa
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapa
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegi
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListabl
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractAppli
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:469)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.jav
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.jav
at com.govoid.task.admin.OrderPriceExportTask.init(OrderPriceExportTask.java:53)
at com.govoid.task.admin.OrderPriceExportTask.main(OrderPriceExportTask.java:46)
后经提醒,是用到的内存不够,在jvm调整参数之后,问题解决
java -server -Xms612m -Xmx612m -Xss612k -XX:PermSize=612m -XX:MaxPermSize=612m -cp lib/*:webapps/ROOT/WEB-INF/lib/*:webapps/ROOT/WEB-INF/classes com.govoid.task.admin.OrderPriceExportTask