未定义父包:jfreechart-default [未知位置]

Parent package is not defined : jfreechart-default [Unknown Location]

我正在尝试使用 Struts2 jfreechart 插件 - 使用 Maven 项目。 在 Maven 依赖项中,我能够看到 jfree-chart jar 文件。

我需要使用单独的软件包吗?

出现以下错误:

SEVERE: Dispatcher initialization failed
Unable to load configuration. - [unknown location]
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70)
    at org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:967)
    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:435)
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:479)
    at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
    at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57)
    at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4828)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5508)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: Parent package is not defined: jfreechart-default - [unknown location]
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.buildPackageContext(XmlConfigurationProvider.java:674)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:523)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:295)
    at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:112)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:264)
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
    ... 17 more

我的struts.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>

    <constant name="struts.devMode" value="true"></constant>


    <package name="basicstruts2" extends="struts-default, jfreechart-default">
        <action name="index">
            <result>/index.jsp</result>
        </action>

        <action name="getchart" class="com.struts.charts.actions.ChartAction"
            method="execute">
            <result name="success" type="chart">
                <param name="width">400</param>
                <param name="height">300</param>
            </result>
        </action>
    </package>



</struts>

struts.xml 中,您使用了要求 struts2-jfreechart-plugin-x.x.x.jar 位于类路径中的代码。这个插件有 struts-plugin.xml 定义了 jfreechart-default 包。如果您的包裹扩展 jfreechart-default.

,则您需要 this
<package name="basicstruts2" extends="struts-default, jfreechart-default">