Java – why doesn’t the runnable jar exported from eclipse work?

I have a project that works well from eclipse

Edit (it was not previously run with - jar):

INFO: Loading XML bean deFinitions from class path resource [applicationContext-
framework.xml]
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(UnkNown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(UnkNown Source)
        at java.lang.reflect.Method.invoke(UnkNown Source)
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoa
der.java:58)
Caused by: org.springframework.beans.factory.BeanDeFinitionStoreException: IOExc
eption parsing XML document from class path resource [applicationContext-framewo
rk.xml]; nested exception is java.io.FileNotFoundException: class path resource
[applicationContext-framework.xml] cannot be opened because it does not exist
        at org.springframework.beans.factory.xml.XmlBeanDeFinitionReader.loadBea
nDeFinitions(XmlBeanDeFinitionReader.java:349)
        at org.springframework.beans.factory.xml.XmlBeanDeFinitionReader.loadBea
nDeFinitions(XmlBeanDeFinitionReader.java:310)
        at org.springframework.beans.factory.support.AbstractBeanDeFinitionReade
r.loadBeanDeFinitions(AbstractBeanDeFinitionReader.java:143)
        at org.springframework.beans.factory.support.AbstractBeanDeFinitionReade
r.loadBeanDeFinitions(AbstractBeanDeFinitionReader.java:178)
        at org.springframework.beans.factory.support.AbstractBeanDeFinitionReade
r.loadBeanDeFinitions(AbstractBeanDeFinitionReader.java:149)
        at org.springframework.beans.factory.support.AbstractBeanDeFinitionReade
r.loadBeanDeFinitions(AbstractBeanDeFinitionReader.java:212)
        at org.springframework.context.support.AbstractXmlApplicationContext.loa
dBeanDeFinitions(AbstractXmlApplicationContext.java:113)
        at org.springframework.context.support.AbstractXmlApplicationContext.loa
dBeanDeFinitions(AbstractXmlApplicationContext.java:80)
        at org.springframework.context.support.AbstractRefreshableApplicationCon
text.refreshbeanfactory(AbstractRefreshableApplicationContext.java:123)
        at org.springframework.context.support.AbstractApplicationContext.obtain
Freshbeanfactory(AbstractApplicationContext.java:422)
        at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:352)
        at org.springframework.context.support.ClassPathXmlApplicationContext.<i
nit>(ClassPathXmlApplicationContext.java:139)
        at org.springframework.context.support.ClassPathXmlApplicationContext.<i
nit>(ClassPathXmlApplicationContext.java:93)
        at com.horstmann.violet.UMLEditorApplication.getApplicationContext(UMLEd
itorApplication.java:111)
        at com.horstmann.violet.UMLEditorApplication.<init>(UMLEditorApplication
.java:94)
        at com.horstmann.violet.UMLEditorApplication.main(UMLEditorApplication.j
ava:84)
        ... 5 more
Caused by: java.io.FileNotFoundException: class path resource [applicationContex
t-framework.xml] cannot be opened because it does not exist
        at org.springframework.core.io.ClassPathResource.getInputStream(ClassPat
hResource.java:143)
        at org.springframework.beans.factory.xml.XmlBeanDeFinitionReader.loadBea
nDeFinitions(XmlBeanDeFinitionReader.java:336)
        ... 20 more

But the file is located in the resource / source jar root directory

What did I miss or do wrong?

Solution

Try clicking the "package required libraries into generated jars" option

Jar files are regular compressed archives Ensure manifest All the necessary libraries in the MF file exist in the generated file

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>