0

我将 Eclipse 与 Maven 集成一起使用,并将 JFXtras 包含在我的项目中。当我进行 Maven 构建时,它成功创建了 jar,但是当我尝试运行它时,我得到了一个

java.lang.ClassNotFoundException: jfxtras.scene.control.ListSpinner

我像这里描述的那样集成了 jfxtras:http: //mvnrepository.com/artifact/org.jfxtras/jfxtras-labs/8.0-r3

编辑:

<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>propgr</groupId>
  <artifactId>Project</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <dependencies>
  <dependency>
    <groupId>org.jfxtras</groupId>
    <artifactId>jfxtras-labs</artifactId>
    <version>8.0-r1</version>
</dependency>
<dependency>
    <groupId>org.jfxtras</groupId>
    <artifactId>jfxtras-controls</artifactId>
    <version>8.0-r1</version>
</dependency>
<dependency>
    <groupId>org.jfxtras</groupId>
    <artifactId>jfxtras-common</artifactId>
    <version>8.0-r1</version>
</dependency>

</dependencies>
  <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>main.Main</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>
</project>

有什么想法/帮助吗?

4

1 回答 1

2

JFXtras 由许多工件组成;labs、controls、common、...,它们之间存在一些依赖关系。缺少实验室的依赖项。下面的 pom 对我有用。

<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>propgr</groupId>
    <artifactId>Project</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>org.jfxtras</groupId>
            <artifactId>jfxtras-labs</artifactId>
            <version>8.0-r3</version>
        </dependency>
    </dependencies>
    <build>
        ...
   </build>
</project>

那是针对一个release,如果要使用snapshot,需要在pom或者.m2/settings.xml中添加Sonatype的snapshot仓库

<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>propgr</groupId>
    <artifactId>Project</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>org.jfxtras</groupId>
            <artifactId>jfxtras-labs</artifactId>
            <version>8.0-r4-SNAPSHOT</version>
        </dependency>
    </dependencies>
    <repositories>
        <repository>
            <id>oss-sonatype</id>
            <name>oss-sonatype</name>
            <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>
    <build>
        ...
   </build>
</project>
于 2015-06-25T05:54:11.350 回答