简体   繁体   中英

Problems with Pom.xml

I hope you guys can help me out. I want to make a simple webLogin (Maven project) so far my code works. Now to make a build and deploy it i had to look into poms and i really tried but i don't know what i am doing wrong. Maybe someone knows how to do it right

My project tree:

我的项目树

pom.xml(project)

<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(rest)

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

This is what i get right now and im sure this will not be the last ERROR i get..

[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]

Maybe someone can help me thanks in advance

Your project structure seems to be broken. You usually have one pom per project, and especially you should not have pom files in the src/main/java. If you want to define modules (subprojects) they need to have their own inner structure (as every Maven project).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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