首页 > 解决方案 > pom.xml 中的 LWJGL 项目错误:缺少工件 org.lwjgl:lwjgl-platform:jar:natives-windows:${lwjgl.version}

问题描述

所以我想自学 LWJGl 的乐趣,所以我制作了项目文件,把东西放到 pom.xml 文件中,然后我得到了这个错误:

缺少工件 org.lwjgl:lwjgl-platform:jar:natives-windows:${lwjgl.version}

这是我的 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>learninglwjgl</groupId>
  <artifactId>learninglwjgl</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>learninglwjgl</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>
     <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-platform</artifactId>
            <version>${lwjgl.version}</version>
            <classifier>${native.target}</classifier>
        </dependency>
  </dependencies>

   <profiles>
        <profile>
            <id>windows-profile</id>
            <activation>
                <os>
                    <family>Windows</family>
                </os>
            </activation>
            <properties>
                <native.target>natives-windows</native.target>
            </properties>                
        </profile>
        <profile>
            <id>linux-profile</id>
            <activation>
                <os>
                    <family>Linux</family>
                </os>
            </activation>
            <properties>
                <native.target>natives-linux</native.target>
            </properties>                
        </profile>
        <profile>
            <id>OSX-profile</id>
            <activation>
                <os>
                    <family>mac</family>
                </os>
            </activation>
            <properties>
                <native.target>natives-osx</native.target>
            </properties>
        </profile>
    </profiles>

</project>

任何帮助将不胜感激,谢谢:)

标签: javamavenlwjgl

解决方案


您应该为${lwjgl.version}. 正如您在Maven Central中看到的,该工件的唯一版本是3.0.0并且您必须明确定义它。请将您的<properties>标签替换为以下内容:

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <lwjgl.version>3.0.0</lwjgl.version>
</properties>

此外,您可能希望使用描述设置 Maven 项目的官方 LWJGL 页面,因为我不确定您是否pom.xml包含所有必要的依赖项。


推荐阅读