【问题标题】:Why strut2-junit plugin complains about convention plugin in?为什么strut2-junit插件抱怨约定插件?
【发布时间】:2016-01-05 09:15:03
【问题描述】:

我在 Maven 中有一个正在运行的项目,Struts 2。我正在尝试添加 struts2-junit-plugin 进行测试。

所以我添加了struts2-junit的插件。

<dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-junit-plugin</artifactId>
    <version>2.3.20</version>
</dependency>

运行后,我得到了这个错误:

java.lang.NoClassDefFoundError: javax/servlet/jsp/PageContext

然后我添加了jsp-api的插件。

<dependency>
    <groupId>javax.servlet.jsp</groupId>
    <artifactId>jsp-api</artifactId>
    <version>2.2</version>
    <scope>prototype</scope>
</dependency>

当我运行它时,我得到了一个不同的错误:

java.io.FileNotFoundException: class path resource [WEB-INF/content/] cannot be resolved to URL because it does not exist

我尝试对我的struts.xml 进行以下更改:

<constant name="struts.convention.result.path" value="/src/main/webapp/WEB-INF"

但它也没有工作。

当我从我的 pom 文件中删除 struts2-convention-plugin 时,它可以工作。

但我需要 struts2-convention-plugin。谁能告诉我这里有什么问题?

【问题讨论】:

    标签: java maven jakarta-ee junit struts2


    【解决方案1】:

    您使用了错误的版本和依赖范围。替换为

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.0</version>
        <scope>provided</scope>
    </dependency>
    

    并使用结果路径的默认配置

    <constant name="struts.convention.result.path" value="/WEB-INF/content" />
    

    【讨论】:

      【解决方案2】:

      我在一位朋友的帮助下得到了解决方案,我没有使用这条线 &lt;constant name="struts.convention.result.path" value="/src/main/webapp/WEB-INF" 在 struts.xml....

      但我在src/main/resources 内创建了文件夹结构WEB_INF/content/user-actions 并且它起作用了。

      【讨论】:

        【解决方案3】:

        我遇到了同样的问题,并通过在 struts.xml 中添加以下行来解决

        &lt;constant name="struts.convention.result.path" value="/" /&gt;

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2012-09-13
          • 1970-01-01
          • 1970-01-01
          • 2015-06-09
          • 2020-08-12
          • 2016-02-27
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多