MVC模板项目中的pom.xml错误 [英] Error with pom.xml in MVC Template project

查看:90
本文介绍了MVC模板项目中的pom.xml错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用STS并创建了Spring MVC Template Project.但是pom.xml告诉我有一个错误,它写道:

I use STS and I've created Spring MVC Template Project. But pom.xml tells me that there is an error and it writes this:

"No plugin found for prefix 'war' in the current project and in the plugin groups [] available from the repositories [local (C:\Users\m1e\.m2\repository), central (http://repo.maven.apache.org/maven2)]"

我是第一次使用STS和Maven,并且是菜鸟.我真的不明白这是什么意思.伙计们,请帮忙.谢谢!

I'm using STS and Maven for the first time and I'm a noob. I really don't understand what the hell it means. Guys, please help. Thanks!

这是我的pom.xml:

Here is my 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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.andrew</groupId>
    <artifactId>mvc</artifactId>
    <name>NewMVC</name>
    <packaging>war</packaging>
    <version>1.0.0-BUILD-SNAPSHOT</version>
    <properties>
        <java-version>1.6</java-version>
        <org.springframework-version>3.1.1.RELEASE</org.springframework-version>
        <org.aspectj-version>1.6.10</org.aspectj-version>
        <org.slf4j-version>1.6.6</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>   


                <!-- Database -->
        <dependency>
            <groupId>mssql</groupId>
            <artifactId>sqljdbc</artifactId>
            <version>4.0</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 -->

        <!-- 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>

        <!-- Hibernate -->
        <dependency>
            <groupId>hibernate</groupId>
            <artifactId>hibernate-commons-annotations</artifactId>
            <version>1.0</version>
        </dependency>
        <!-- Hibernate -->
        <dependency>
            <groupId>hibernate</groupId>
            <artifactId>hibernate-annotations</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>hibernate</groupId>
            <artifactId>hibernate</artifactId>
            <version>3.0</version>
        </dependency>
        <dependency>
            <groupId>persistence</groupId>
            <artifactId>persistence</artifactId>
            <version>1.0</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.9</version>
                <configuration>
                    <additionalProjectnatures>
                        <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
                    </additionalProjectnatures>
                    <additionalBuildcommands>
                        <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
                    </additionalBuildcommands>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>true</downloadJavadocs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <compilerArgument>-Xlint:all</compilerArgument>
                    <showWarnings>true</showWarnings>
                    <showDeprecation>true</showDeprecation>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2.1</version>
                <configuration>
                    <mainClass>org.test.int1.Main</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>


</project>

推荐答案

mmm我要检查的第一件事是Maven版本.

mmm The first thing that I would check is the Maven Version.

您使用的是哪个STS版本?最后一个是 3.1.0 ,它随 Maven 3.0.4版本

What STS version are you using? The last one is the 3.1.0 and it is supplied with Maven 3.0.4 version

那么,为什么要使用较旧的Maven 2版本?

So why are you using the older Maven 2 version?

问题似乎取决于缺少特定的Maven插件

The problem seems to depend on the absence of a specific Maven plugin

尝试:

1)删除./m2目录中的存储库文件夹,然后进入STS进行项目的全新安装或maven安装,然后查看它是否有效(有时理解为您下载任何内容都不正确)

1) Delete the repositery folder inside your ./m2 directory, then go in STS and do a clean or a maven install of your project and see if it works (sometimes understood you wrong to download anything)

如果不使用最新的Maven版本,则较旧的版本可能与在Spring模板项目的pom.xml文件中声明的插件有问题...如果您下载了最新版本的Maven,则在teory中STS您还拥有Maven的最新版本!!!

If don't work use the last Maven version, maybe the older version have some problem with the plugin declared in the pom.xml file of the Spring Template project...in teory, if you have dowload the latest version of STS you have also the latest version of Maven !!!

这篇关于MVC模板项目中的pom.xml错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆