【发布时间】:2013-11-19 23:26:19
【问题描述】:
documents.jsp顶部的以下三行在this tutorial使用eclipse和maven的spring框架应用程序中抛出“cannot find tag library descriptor for ...”错误:
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
我的理解是eclipse的maven插件应该自动管理这些库的下载,所以我检查确保pom.xml中包含以下内容:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<properties>
<org.springframework.version>3.0.2.RELEASE</org.springframework.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
那么如何修复我的应用程序以启用所需的依赖项?我想避免手动操作,因为我的印象是 maven 应该管理这个。有什么方法需要我操纵 Maven 吗?该应用程序在针对本教程进行测试时显然有效。
编辑:
我将我的 eclipse 项目转换为 maven 项目,然后右键单击 eclipse 项目并选择 Maven>Update Project。这并没有解决我上面原始帖子中仍然存在的错误,但它还添加了以下新错误:
Missing artifact javax.transaction:jta:jar:1.0.1B
现在是pom.xml的第二行抛出的,内容如下:
<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
第二次编辑:
当我尝试在服务器上运行 as..run 时,我在对话框中收到以下错误:
'Publishing to Tomcat v7.0 Server at localhost...' has encountered a problem.
Error reading file D:\mypath\.m2\repository\javax\transaction\jta\1.0.1B\jta-1.0.1B.jar
D:\mypath\.m2\repository\javax\transaction\jta\1.0.1B\jta-1.0.1B.jar (The system cannot find the file specified)
我什至在Window>preferences>Maven中设置了“启动时更新Maven项目”,然后关闭并重新启动eclipse,但问题仍然存在。
【问题讨论】:
-
你确定这对于 spring 而不是核心 taglibs 失败了吗?你能添加堆栈跟踪吗?
-
@benjamin.d 我刚刚在 Eclipse 中查看代码,所以没有堆栈跟踪。当我阅读您的评论时,我尝试运行为...在服务器上运行,并在我对原始帖子的第二次编辑中显示了错误对话框,这是我刚刚在上面添加的。
-
只要它在项目的 Java 构建路径中不知何故,就会被找到。可能是 Maven 更新项目的方法没有触发正确的刷新。尝试关闭然后打开项目以强制它。