当我在新的java 8项目中尝试使用与javafx相关的类时,我从eclipse中获得了访问限制错误.到目前为止,我能找到的唯一"解决方案"是告诉eclipse忽略访问限制,但我对此并不满意.错误的一个例子:
Access restriction: The type Pane is not accessible due to
restriction on required library C:\Program Files\Java\jre8_0\lib\ext\jfxrt.jar
Run Code Online (Sandbox Code Playgroud)
我正在使用Eclipse Kepler和Java 8的Eclipse JDT补丁.
这似乎是与JavaFX不是JavaSE执行环境的一部分有关的问题.
我现在很困惑,因为根据http://en.wikipedia.org/wiki/JavaFX,javaFX是JavaSE的一部分.是否有可能Eclipse没有认识到它是javaSE的一部分?
如何Unknown property:在Eclipse Mars上编写JavaFx css属性时禁用eclipse中的错误?
例如:Unknown property: "-fx-background-color"in-fx-background-color: #CCFF99;
为了避免对jfxrt.jar的非法访问警告,我手动将类路径文件更改为包括访问规则:
想要的类路径条目
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
<accessrules>
<accessrule kind="accessible" pattern="javafx/**"/>
<accessrule kind="accessible" pattern="com/sun/javafx/**"/>
</accessrules>
</classpathentry>
Run Code Online (Sandbox Code Playgroud)
如果我执行pom.xml文件,则标签accessrule会被删除,新条目为
当前由pom.xml / M2E生成的类路径条目
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
Run Code Online (Sandbox Code Playgroud)
这是因为有关访问规则的信息未包含在我的pom.xml文件中。如何修改pom.xml文件以生成所需的类路径文件?
我可以对Maven-compiler-plugin使用一些配置吗?
还是我必须使用一些额外的Maven插件来修改类路径文本文件?
还是根本无法在pom.xml文件中解决此问题,而我将不得不为M2E编写功能请求?
这是我的pom.xml文件中的一个片段(我使用pom打包):
当前的pom.xml条目用于编译阶段
<!-- ### COMPILE ### phase -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<!-- specify current java version here: -->
<source>1.8</source>
<target>1.8</target>
</configuration>
<executions>
<execution>
<id>compile-execution</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>org.treez.test-compile-execution</id>
<phase>org.treez.test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)