简体   繁体   English

运行Spring3教程Build错误

[英]Running Spring3 tutorial Build error

I am doing a Spring3 tutorial. 我正在做一个Spring3教程。 i downloaded the code from this tutorial . 我从本教程中下载了代码。 When i try to run it i get the following errors; 当我尝试运行它时,出现以下错误; I think i might be missing 1 or 2 Jar files. 我想我可能会丢失1或2个Jar文件。 Can someone help me by pointing which Jar file i need to install and the link to do so. 有人可以通过指出我需要安装哪个Jar文件以及链接来帮助我。

Description Resource Path Location Type Can not find the tag library descriptor for "http://java.sun.com/jsp/jstl/core" contact.jsp /Spring3HibernateMaven/src/main/webapp/WEB-INF/jsp line 3 JSP Problem 说明资源路径位置类型找不到“ http://java.sun.com/jsp/jstl/core”的标签库描述符contact.jsp / Spring3HibernateMaven / src / main / webapp / WEB-INF / jsp第3行JSP问题

Description Resource Path Location Type Can not find the tag library descriptor for "http://www.springframework.org/tags" contact.jsp /Spring3HibernateMaven/src/main/webapp/WEB-INF/jsp line 1 JSP Problem 说明资源路径位置类型找不到“ http://www.springframework.org/tags”的标签库描述符contact.jsp / Spring3HibernateMaven / src / main / webapp / WEB-INF / jsp第1行JSP问题

Description Resource Path Location Type Can not find the tag library descriptor for "http://www.springframework.org/tags/form" contact.jsp /Spring3HibernateMaven/src/main/webapp/WEB-INF/jsp line 2 JSP Problem 说明资源路径位置类型找不到“ http://www.springframework.org/tags/form”的标签库描述符contact.jsp / Spring3HibernateMaven / src / main / webapp / WEB-INF / jsp第2行JSP问题

2nd Error 第二次错误

Description Resource Path Location Type 说明资源路径位置类型

Description Resource Path Location Type Autowired cannot be resolved to a type ContactController.java /Spring3HibernateMaven/src/main/java/net/viralpatel/contact/controller line 19 Java Problem 描述资源路径位置类型Autowired无法解析为ContactController.java / Spring3HibernateMaven / src / main / java / net / viralpatel / contact / controller第19行Java问题

Description Resource Path Location Type BindingResult cannot be resolved to a type ContactController.java /Spring3HibernateMaven/src/main/java/net/viralpatel/contact/controller line 33 Java Problem 说明资源路径位置类型BindingResult无法解析为类型ContactController.java / Spring3HibernateMaven / src / main / java / net / viralpatel / contact / controller第33行Java问题

Description Resource Path Location Type Entity cannot be resolved to a type Contact.java /Spring3HibernateMaven/src/main/java/net/viralpatel/contact/form line 9 Java Problem 说明资源路径位置类型实体无法解析为Contact.java / Spring3HibernateMaven / src / main / java / net / viralpatel / contact / form第9行Java问题

There are 2 types of errors here, can some one help me resolve it. 这里有2种错误,有些可以帮助我解决。

@Illep: I was following the same tutorial and including @Illep:我遵循相同的教程,包括

<properties>
 <org.springframework.version>3.1.0.RELEASE</org.springframework.version>
</properties>

<!-- ... -->

<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-webmvc</artifactId>
  <version>${org.springframework.version}</version>
</dependency>

<!-- ... -->

in pom.xml and puting a space between 在pom.xml中,并在

prefix="spring" %>

did the trick. 做到了。

This is tutorial uses maven. 这是本教程使用的maven。 Unfortunaly it looks like they forget to specifiy the maven dependencies in the pom.xml. 不幸的是,他们似乎忘记了在pom.xml中指定Maven依赖项。

So you can try to fix it, or try an other tutorial. 因此,您可以尝试修复它,或尝试其他教程。 ( I know I have mentioned this tutorial in one of my previous answers, but the question there was about the general structure of spring web controllers. -- sorry for the trouble ) 我知道我在先前的回答中已经提到了本教程,但是这里的问题是关于Spring Web控制器的一般结构。-麻烦您了

You can try this pom ( I have not tested it, but I feel a bit guilty ): 您可以尝试使用此pom( 我尚未测试过,但我感到有点内gui ):

<?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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.test</groupId>
    <artifactId>test</artifactId>
    <name>abc</name>
    <packaging>war</packaging>
    <version>1.0.0-BUILD-SNAPSHOT</version>
    <properties>
        <java-version>1.6</java-version>
        <org.springframework-version>3.0.6.RELEASE</org.springframework-version>
        <org.aspectj-version>1.6.9</org.aspectj-version>
        <org.slf4j-version>1.5.10</org.slf4j-version>
    </properties>
    <dependencies>
        <!-- Spring -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${org.springframework-version}</version>
            <exclusions>
                <!-- Exclude Commons Logging in favor of SLF4j -->
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                 </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${org.springframework-version}</version>
        </dependency>

        <!-- AspectJ -->
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>${org.aspectj-version}</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>3.6.0.Final</version>
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.0.0.GA</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>4.1.0.Final</version>
        </dependency>
       <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>${spring.framework.version}</version>
        </dependency>
        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>1.2.2</version>
        </dependency>       
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>1.3.156</version>
        </dependency>

        <!-- Logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${org.slf4j-version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>${org.slf4j-version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>${org.slf4j-version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.15</version>
            <exclusions>
                <exclusion>
                    <groupId>javax.mail</groupId>
                    <artifactId>mail</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.jms</groupId>
                    <artifactId>jms</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.sun.jdmk</groupId>
                    <artifactId>jmxtools</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.sun.jmx</groupId>
                    <artifactId>jmxri</artifactId>
                </exclusion>
            </exclusions>
            <scope>runtime</scope>
        </dependency>

        <!-- @Inject -->
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
        </dependency>

        <!-- Servlet -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>

        <!-- Test -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.7</version>
            <scope>test</scope>
        </dependency>        
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${java-version}</source>
                    <target>${java-version}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <warName>abc</warName>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>install</id>
                        <phase>install</phase>
                        <goals>
                            <goal>sources</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.5</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM