gpt4 book ai didi

java - 如何将 wurfl 集成到我们的 jar 文件中

转载 作者:太空宇宙 更新时间:2023-11-04 08:17:59 25 4
gpt4 key购买 nike

我为 jar 制作了一个类文件。这个类有使用wurfl。并在 javac 中运行此代码,输出正常。但我制作 jar 文件然后给出错误。

整合wurfl:

 ApplicationContext ctx = new ClassPathXmlApplicationContext("/resources/wurfl-standard-import-ctx.xml");
WURFLManager wurflManager = (WURFLManager) ctx.getBean("wurflManager");

我制作了 jar 文件并运行它。然后出现错误:

org.springframework.beans.factory.BeanCreationException: Error creating bean wit
h name 'wurflModel' defined in class path resource [resources/wurfl-standard-imp
ort-ctx.xml]: Error setting property values; nested exception is org.springframe
work.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (2) are
:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException:
Property 'wurfl' threw exception; nested exception is net.sourceforge.wurfl.core
.resource.WURFLResourceException: WURFL unexpected exception
PropertyAccessException 2: org.springframework.beans.MethodInvocationException:
Property 'wurflPatch' threw exception; nested exception is net.sourceforge.wurfl
.core.resource.WURFLResourceException: WURFL unexpected exception
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1361)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
an(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.
preInstantiateSingletons(DefaultListableBeanFactory.java:580)
at org.springframework.context.support.AbstractApplicationContext.finish
BeanFactoryInitialization(AbstractApplicationContext.java:900)
at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:455)
at org.springframework.context.support.ClassPathXmlApplicationContext.<i
nit>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<i
nit>(ClassPathXmlApplicationContext.java:83)
at mwp.slktechlabs.cron.AnalyticsCron.setNewdataInUserResponseCollection
(AnalyticsCron.java:116)
at mwp.slktechlabs.cron.AnalyticsCron.fillAnalyticsData(AnalyticsCron.ja
va:92)
at mwp.slktechlabs.cron.AnalyticsCron.main(AnalyticsCron.java:44)
Caused by: org.springframework.beans.PropertyBatchUpdateException; nested Proper
tyAccessExceptions (2) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException:
Property 'wurfl' threw exception; nested exception is net.sourceforge.wurfl.core
.resource.WURFLResourceException: WURFL unexpected exception
PropertyAccessException 2: org.springframework.beans.MethodInvocationException:
Property 'wurflPatch' threw exception; nested exception is net.sourceforge.wurfl
.core.resource.WURFLResourceException: WURFL unexpected exception
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(
AbstractPropertyAccessor.java:102)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(
AbstractPropertyAccessor.java:58)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1358)
... 15 more

最佳答案

将您的资源包包含在您的 jar 中,并在此资源包静态文件中包含此代码。

<property name="wurfl" value="file:./resources/wurfl-2.2.zip"/>
<property name="wurflPatch" value="file:./resources/web_browsers_patch.xml"/>

在此代码中使用文件协议(protocol)。

关于java - 如何将 wurfl 集成到我们的 jar 文件中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10105821/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com