简体   繁体   English

使用maven generate生成一个Web应用程序

[英]Generate a web application using maven generate

I have generated a project struture using maven using mvn archetype:generate and the project structure is as follows: webapps -src -main -java -com -web -App.java -test 我已经使用mvn archetype:generate使用maven生成了一个项目结构,项目结构如下:webapps -src -main -java -com -web -App.java -test

I have tried following the tutorial on the link create web app 我尝试按照链接创建网络应用上的教程进行操作

Running mvn dependency:analyze-dep-mgt 运行MVN依赖项:analyze-dep-mgt

but still the project structure differs. 但是项目结构仍然不同。

While I use this mvn archetype:generate -DgroupId={project-packaging} -DartifactId={project-name} -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false, I get Pom file missing 当我使用此mvn archetype:generate -DgroupId={project-packaging} -DartifactId={project-name} -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false,我得到缺少的Pom文件

Where am I being wrong so that the struture differs and my web.xml not being generated? 我在哪里错了,以致结构不同并且没有生成我的web.xml?

C:\Users\user\workspace\webappspringapp\webapp>mvn dependency:analyze-dep-mgt
[INFO] Scanning for projects...
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR]   The project com.webapp:webapp:1.0-SNAPSHOT (C:\Users\user\workspace\we
bappspringapp\webapp\pom.xml) has 3 errors
[ERROR]     'dependencies.dependency.version' for org.springframework:spring-cor
e:jar must be a valid version but is '${spring.version}'. @ line 14, column 13
[ERROR]     'dependencies.dependency.version' for org.springframework:spring-web
:jar must be a valid version but is '${spring.version}'. @ line 20, column 13
[ERROR]     'dependencies.dependency.version' for org.springframework:spring-web
mvc:jar must be a valid version but is '${spring.version}'. @ line 26, column 13

[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[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 rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildin
gException

Pom.xml part Pom.xml部分

<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>
mvn dependency:tree

This is used to view the dependency hierarchy of the project currently being built. 这用于查看当前正在构建的项目的依赖关系层次结构。 It will output the resolved tree of dependencies that the Maven build process actually uses. 它将输出Maven构建过程实际使用的已解析依赖关系树。

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

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