我希望你们能帮助我。 到目前为止,我想制作一个简单的webLogin(Maven项目),我的代码可以工作。现在要进行构建和部署,我必须看看poms,我真的尝试了,但我不知道我做错了什么。也许有人知道如何正确地做到这一点
我的项目树:
的pom.xml(项目)
<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>org.apache.maven</groupId>
<artifactId>LoginTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>LoginTest</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
的pom.xml(APP)
<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>src.main.java</groupId>
<artifactId>app</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<parent>
<groupId>org.apache.maven</groupId>
<artifactId>LoginTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>/pom.xml</relativePath>
</parent>
<profiles>
<profile>
<id>dev</id>
<properties>
<env>dev</env>
<exclude-ui>false</exclude-ui>
<api.ctx.root>/rest</api.ctx.root>
<ui.ctx.root>/webui</ui.ctx.root>
</properties>
</profile>
</profiles>
</project>
的pom.xml(其余部分)
<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>src.main.java</groupId>
<artifactId>rest</artifactId>
<packaging>war</packaging>
<parent>
<groupId>org.apache.maven</groupId>
<artifactId>LoginTest</artifactId>
<version>1.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>src.main.java.app</groupId>
<artifactId>Login.java</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<webXml>src\main\webapp\WEB-INF\web.xml</webXml>
<packagingExcludes>WEB-INF/lib/*intf*.jar,WEB-INF/lib/*shared*.jar</packagingExcludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
的pom.xml(WebUI中)
<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>src.main.java</groupId>
<artifactId>webui</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<parent>
<groupId>org.apache.maven</groupId>
<artifactId>LoginTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<profiles>
<profile>
<id>dev</id>
<properties>
<env>dev</env>
<exclude-ui>false</exclude-ui>
<api.ctx.root>/rest</api.ctx.root>
<ui.ctx.root>/webui</ui.ctx.root>
</properties>
</profile>
</profiles>
</project>
这就是我现在得到的,我确定这不会是我得到的最后一次错误..
[ERROR] Non-resolvable parent POM for src.main.java:app:1.0.0: Could not find artifact org.apache.maven:LoginTest:pom:0.0.1-SNAPSHOT and 'parent.relativePath' points at wrong local POM @ line 12, column 10 -> [Help 2]
也许有人可以提前帮助我
答案 0 :(得分:0)
您的项目结构似乎已被打破。每个项目通常有一个 pom,特别是你不应该在src / main / java中有pom文件。如果要定义模块(子项目),则需要拥有自己的内部结构(如每个Maven项目)。