ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

java – 新Maven / Spring MVC项目的最小pom.xml文件

2019-07-23 00:18:18  阅读:315  来源: 互联网

标签:java spring maven eclipse pom-xml


我是Maven和Spring MVC的新手.我想要做的是使用Maven设置一个新的Spring MVC项目(希望这句话很有意义),然后使用Eclipse在Tomcat上运行我的Web应用程序.

我正在关注此链接的教程,我有一个pom.xml文件的问题:

> Getting Started with Maven and Spring

本教程要求创建文件夹结构,并创建pom.xml文件.对于初学者,他们要求将此行放在pom.xml中:

xml 4.0.0org.springsource.greenbeans.mavenexample11.0-SNAPSHOTOur Simple Project

但是当我这样做时,我的Eclipse会抛出一个错误:

[INFO] Scanning for projects...
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR]   The project  (D:\projectName\pom.xml) has 1 error
[ERROR]     Non-parseable POM D:\projectName\pom.xml: only whitespace content allowed before start tag and not ` (position: START_DOCUMENT seen `... @1:1)  @ line 1, column 1 -> [Help 2]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/ModelParseException

关于正确的最小pom.xml是什么的任何想法?我尝试了很多东西,但它对我不起作用……

解决方法:

您无需自己创建文件夹结构. Maven archtype’maven-archetype-webapp’为你做到了.这是一个很好的教程,可以指导您在eclipse中基本设置MVC项目(以及正确的方法):

> Create Spring MVC dynamic web project with Maven and make it support Eclipse IDE

<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.beingjavaguys.sample</groupId>
<artifactId>SampleSpringMaven</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>SampleSpringMaven Maven Webapp</name>
<url>http://maven.apache.org</url>

<properties>
    <spring.version>3.0.5.RELEASE</spring.version>
    <jdk.version>1.6</jdk.version>
</properties>

<dependencies>

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

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

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

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <finalName>SampleSpringMaven</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.1</version>
            <configuration>
                <url>http://localhost:8080/manager/text</url>
                <server>my-tomcat</server>
                <path>/SampleSpringMaven</path>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.0</version>
            <configuration>
                <source>${jdk.version}</source>
                <target>${jdk.version}</target>
            </configuration>
        </plugin>
    </plugins>
</build>

标签:java,spring,maven,eclipse,pom-xml
来源: https://codeday.me/bug/20190722/1507847.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有