我目前正在使用Quick Books Online SDK,他们的一些代码引发了一个未找到类的错误。有人遇到过这个问题或类似的问题吗?
我看了他们的HelloWorld应用程序示例,没有发现与我当前的实现有任何不同。此外,我真的只需要他们的默认配置。
导致错误的方法=>
/**
* Extracts environment properties on a JRE < 1.5. This implementation
* uses ant for this purpose.
*/
void extractProperties14()
{
extractPropertiesFromCollection(Execute.getProcEnvironment());
}
TRACE=>
java.lang.ClassNotFoundException: org.apache.tools.ant.taskdefs.Execute
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583) ~[na:na]
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[na:na]
at org.apache.commons.configuration.EnvironmentConfiguration.extractProperties14(EnvironmentConfiguration.java:160) ~[commons-configuration-1.6.jar:1.6]
at org.apache.commons.configuration.EnvironmentConfiguration.<init>(EnvironmentConfiguration.java:77) ~[commons-configuration-1.6.jar:1.6]
at com.intuit.ipp.util.Config.<init>(Config.java:218) ~[ipp-v3-java-devkit-4.0.3-jar-with-dependencies.jar:na]
at com.intuit.ipp.util.Config.<init>(Config.java:30) ~[ipp-v3-java-devkit-4.0.3-jar-with-dependencies.jar:na]
at com.intuit.ipp.util.Config$1.initialValue(Config.java:188) ~[ipp-v3-java-devkit-4.0.3-jar-with-dependencies.jar:na]
at com.intuit.ipp.util.Config$1.initialValue(Config.java:186) ~[ipp-v3-java-devkit-4.0.3-jar-with-dependencies.jar:na]
at java.base/java.lang.ThreadLocal.setInitialValue(ThreadLocal.java:195) ~[na:na]
at java.base/java.lang.ThreadLocal.get(ThreadLocal.java:172) ~[na:na]
at com.intuit.ipp.util.Config$1.get(Config.java:192) ~[ipp-v3-java-devkit-4.0.3-jar-with-dependencies.jar:na]
at com.intuit.ipp.util.Config$1.get(Config.java:186) ~[ipp-v3-java-devkit-4.0.3-jar-with-dependencies.jar:na]
at com.intuit.ipp.util.Config.setProperty(Config.java:247) ~[ipp-v3-java-devkit-4.0.3-jar-with-dependencies.jar:na]
at com.incursus.patch.helper.QBOServiceHelper.getDataService(QBOServiceHelper.java:24) ~[classes/:na]
at com.incursus.patch.web.PortalController.callQBOCompanyInfo(PortalController.java:89) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:215) ~[spring-web-5.1.2.RELEASE.jar:5.1.2.RELEASE]
您可能遇到与应用程序类路径上缺少库有关的问题
所以基本上你可以尝试两种选择:
- 找到兼容版本并在类路径上添加Apache Ant Core
- 尝试将
apache-commons-configuration 1.6
升级到不需要Execute
类的apache-commons-configuration 1.10
以下是当前版本1.10:中EnvironmentConfiguration
的源代码
/**
* Create a Configuration based on the environment variables.
*
* @see System#getenv()
*/
public EnvironmentConfiguration()
{
super(new HashMap<String, Object>(System.getenv()));
}
当然,如果升级版本在运行时不会导致任何不兼容,则必须进行测试和验证。