2013-12-20 3 views
3

전적으로 Maven과 Spring MVC를 처음 사용합니다. 내가하고 싶은 일은 Maven을 사용하여 새로운 Spring MVC 프로젝트를 설정하는 것이다. Eclipse를 사용하여 Tomcat에서 내 웹 애플리케이션을 실행한다.새로운 Maven/Spring MVC 프로젝트를위한 최소 pom.xml 파일

것은 나는이 링크에서 자습서를 따라하고 있는데이 pom.xml 파일에 문제가 있습니다

튜토리얼 폴더 구조를 생성하고 치어를 만들 요청합니다. XML 파일.

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

을하지만 그렇게 할 때, 내 이클립스 오류가 발생합니다 : 우선 그들은 pom.xml 파일에서이 줄을 넣어 무엇을 물어 권리 최소 치어에

[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 

어떤 생각을. XML 수 있습니다? 나는 많은 것을 시도했지만 그것은 나를 위해 작동하지 않았다. ...

답변

8

당신은 당신 자신의 폴더 구조를 만들 필요가 없다. Maven 아치 유형 'maven-archetype-webapp'이이 작업을 수행합니다. 여기에 기본 설정까지 이클립스에서 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> 
    

+0

멋진 당신에게 @Amit 감사합니다. 내 방식대로 시도해보십시오 :) – Myna

+0

@Myna 도와 드리겠습니다. –

+0

이봐, "Eclipse에서 Maven 프로젝트 실행"부분에 문제가 있습니다. junit 만 볼 수 있습니다. 명령 추적은 다음과 같습니다. [...] Eclipse Workspace 사용 : null 기본 클래스 경로 컨테이너 추가 : org.eclipse.jdt.launching.JRE_CONTAINER 설정 작성 안 함 - 기본값은 D : \ Users \ FirstMavenProject로 충분합니다. \. 프로젝트가 이미 있습니다. 추가 설정이 유지되며 이전 설정을 제거하려면 mvn eclipse : clean을 실행하십시오. "FirstMavenProject"에 대한 Eclipse 프로젝트를 D : \ Users \ FirstMavenProject에 작성했습니다. 내가 .jars를 모두 가져 오지 못하는 이유는 무엇입니까? – Myna

1

최소 pom.xml Tomcat이있는 Spring MVC 용 파일은 다음과 같습니다.

<?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"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>com.spring.maven</groupId> 
    <artifactId>minimal-spring</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <packaging>war</packaging> 

    <dependencies> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-webmvc</artifactId> 
      <version>4.3.5.RELEASE</version> 
     </dependency> 
    </dependencies> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.tomcat.maven</groupId> 
       <artifactId>tomcat7-maven-plugin</artifactId> 
       <version>2.2</version> 
       <configuration> 
        <path>/</path> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 
</project> 

: 그리고

$ mvn -Dmaven.tomcat.port=8888 tomcat7:run 
관련 문제