为什么struts2-junit插件会抱怨中的约定插件?

yws3nbqq  于 2022-11-11  发布在  其他
关注(0)|答案(3)|浏览(115)

我在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。有人能告诉我这里的问题是什么吗?

ws51t4hk

ws51t4hk1#

我得到了我的一个朋友的帮助解决方案,我没有使用struts.xml中的<constant name="struts.convention.result.path" value="/src/main/webapp/WEB-INF"这一行....
但是我在src/main/resources中创建了文件夹结构WEB_INF/content/user-actions,它工作了。

pdkcd3nj

pdkcd3nj2#

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

<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" />
67up9zun

67up9zun3#

我遇到了同样的问题,通过在struts.xml中添加下面的行解决了这个问题
<constant name="struts.convention.result.path" value="/" />

相关问题