application.xml 在 Eclipse 中修改导致部署问题

application.xml modified in Eclipse causes deployment issue

将 Maven 项目导入 Eclipse 时(有时只是刷新工作区),文件 application.xml 被修改并导致将 EAR 部署到 Jboss 5:

org.jboss.deployers.spi.DeploymentException: Exception determining structure: AbstractVFSDeployment
Caused by: org.jboss.xb.binding.JBossXBRuntimeException: {http://java.sun.com/xml/ns/j2ee}library-directory cannot appear in this position. Expected content of {http://java.sun.com/xml/ns/j2ee}application is unordered_sequence: {http://java.sun.com/xml/ns/j2ee}module* {http://java.sun.com/xml/ns/j2ee}security-role* {all {http://java.sun.com/xml/ns/j2ee}descriptionGroup}?

IDE 已替换:

<application version="1.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">

作者:

<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:application="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd" version="1.4">

并已添加:

<library-directory>lib/</library-directory>

发生在 Eclipse Mars 和 Eclipse Luna 上, 这是因为 IDE 中的某些配置吗?

这是由于 Eclipse 配置所致。尝试 Window - Preferences,然后 Maven -> Java EE Integration 并取消选中 'Enable Java EE Integration',如下所示。您还需要确保没有为任何特定项目单独设置首选项(右键单击该项目并选择 'Properties' 然后选择相同的 Maven -> Java EE Integration')。