当前位置: 首页 > 知识库问答 >
问题:

Apache Ant Ivy语法错误

方博
2023-03-14

我刚刚使用apache ant设置了我的第一个项目,ivy作为依赖项管理器。它工作得很好!但是有一件事我无法释怀。因为我有几个使用slf4j的依赖项,所以存在版本不匹配的冲突。所以我在ivy.xml中定义了一个conflict标签来强制某个版本(本例中是1.5.6)。使用eclipse插件IvyIDE运行Ivy resolve不会出错。但是当使用我的ant构建文件来构建我的应用程序时,我得到了一个xml语法错误:

Apache Ant(TM) version 1.8.2 compiled on December 20 2010
Buildfile: B:\core-lib\build.xml
parsing buildfile B:\core-lib\build.xml with URI = file:/B:/core-lib/build.xml
Project base dir set to: B:\core-lib
parsing buildfile jar:file:/C:/Program%20Files/InformDevTools/eclipse/plugins/org.apache.ant_1.8.2.v20120109-1030/lib/ant.jar!/org/apache/tools/ant/antlib.xml with URI = jar:file:/C:/Program%20Files/InformDevTools/eclipse/plugins/org.apache.ant_1.8.2.v20120109-1030/lib/ant.jar!/org/apache/tools/ant/antlib.xml from a zip file
Build sequence for target(s) `resolve' is [clean, init, resolve]
Complete build sequence is [clean, init, resolve, compile, resources, test, dist, ]
clean:
   [delete] Deleting directory B:\core-lib\build
   [delete] Deleting directory B:\core-lib\build\lib
   [delete] Deleting directory B:\core-lib\build\main
   [delete] Deleting directory B:\core-lib\build\report\test
   [delete] Deleting directory B:\core-lib\build\report
   [delete] Deleting directory B:\core-lib\build\test
   [delete] Deleting directory B:\core-lib\build
   [delete] Deleting directory B:\core-lib\dist
   [delete] Deleting directory B:\core-lib\dist
init:
Override ignored for property "DSTAMP"
Override ignored for property "TSTAMP"
Override ignored for property "TODAY"
    [mkdir] Created dir: B:\core-lib\build
    [mkdir] Created dir: B:\core-lib\build\main
    [mkdir] Created dir: B:\core-lib\build\lib
    [mkdir] Created dir: B:\core-lib\dist
    [mkdir] Created dir: B:\core-lib\build\test
    [mkdir] Created dir: B:\core-lib\build\report\test
resolve:
parsing buildfile jar:file:/C:/Users/admin/.eclipse/org.eclipse.platform_3.7.0_1992851616/plugins/org.apache.ivy.eclipse.ant_2.3.0.cr120120416000235/ivy.jar!/org/apache/ivy/ant/antlib.xml with URI = jar:file:/C:/Users/admin/.eclipse/org.eclipse.platform_3.7.0_1992851616/plugins/org.apache.ivy.eclipse.ant_2.3.0.cr120120416000235/ivy.jar!/org/apache/ivy/ant/antlib.xml from a zip file
[ivy:retrieve] No ivy:settings found for the default reference 'ivy.instance'.  A default instance will be used
[ivy:retrieve] Loading jar:file:/C:/Users/admin/.eclipse/org.eclipse.platform_3.7.0_1992851616/plugins/org.apache.ivy.eclipse.ant_2.3.0.cr120120416000235/ivy.jar!/org/apache/ivy/core/settings/ivy.properties
[ivy:retrieve] searching settings file: trying B:\core-lib\ivysettings.xml
[ivy:retrieve] :: Apache Ivy 2.3.0-rc1 - 20120416000235 :: http://ant.apache.org/ivy/ ::
[ivy:retrieve] jakarta commons httpclient not found: using jdk url handling
[ivy:retrieve] :: loading settings :: file = B:\core-lib\ivysettings.xml
[ivy:retrieve] no default ivy user dir defined: set to C:\Users\admin\.ivy2
[ivy:retrieve] no default cache defined: set to C:\Users\admin\.ivy2\cache
[ivy:retrieve] settings loaded (31ms)
[ivy:retrieve]  default cache: C:\Users\admin\.ivy2\cache
[ivy:retrieve]  default resolver: inform-artifactory
[ivy:retrieve]  -- 5 resolvers:
[ivy:retrieve]  inform [release] [ibiblio]
[ivy:retrieve]  inform [snapshot] [ibiblio]
[ivy:retrieve]  inform [proxied] [ibiblio]
[ivy:retrieve]  inform-artifactory [chain] [inform [proxied], inform  [third-party], inform [release], inform [snapshot]]
[ivy:retrieve]  inform  [third-party] [ibiblio]
[ivy:retrieve] no resolved descriptor found: launching default resolve
Overriding previous definition of property "ivy.version"
[ivy:retrieve] using ivy parser to parse file:/B:/core-lib/ivy.xml
[ivy:retrieve] [xml parsing: ivy.xml:28:108: cvc-complex-type.2.4.a: Ungültiger Content wurde beginnend mit Element "dependency" gefunden. "{conflict}" wird erwartet. in file:/B:/core-lib/ivy.xml
[ivy:retrieve] ]

BUILD FAILED
B:\core-lib\build.xml:77: syntax errors in ivy file: java.text.ParseException: [xml parsing: ivy.xml:28:108: cvc-complex-type.2.4.a: Ungültiger Content wurde beginnend mit Element "dependency" gefunden. "{conflict}" wird erwartet. in file:/B:/core-lib/ivy.xml
]
    at org.apache.ivy.ant.IvyResolve.doExecute(IvyResolve.java:396)
    at org.apache.ivy.ant.IvyTask.execute(IvyTask.java:277)
    at org.apache.ivy.ant.IvyPostResolveTask.ensureResolved(IvyPostResolveTask.java:231)
    at org.apache.ivy.ant.IvyPostResolveTask.prepareAndCheck(IvyPostResolveTask.java:178)
    at org.apache.ivy.ant.IvyRetrieve.doExecute(IvyRetrieve.java:87)
    at org.apache.ivy.ant.IvyTask.execute(IvyTask.java:277)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
    at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:390)
    at org.apache.tools.ant.Target.performTasks(Target.java:411)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    at org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
    at org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:424)
    at org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:138)
Caused by: java.text.ParseException: [xml parsing: ivy.xml:28:108: cvc-complex-type.2.4.a: Ungültiger Content wurde beginnend mit Element "dependency" gefunden. "{conflict}" wird erwartet. in file:/B:/core-lib/ivy.xml
]
    at org.apache.ivy.plugins.parser.AbstractModuleDescriptorParser$AbstractParser.checkErrors(AbstractModuleDescriptorParser.java:89)
    at org.apache.ivy.plugins.parser.AbstractModuleDescriptorParser$AbstractParser.getModuleDescriptor(AbstractModuleDescriptorParser.java:344)
    at org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParser.parseDescriptor(XmlModuleDescriptorParser.java:117)
    at org.apache.ivy.plugins.parser.AbstractModuleDescriptorParser.parseDescriptor(AbstractModuleDescriptorParser.java:48)
    at org.apache.ivy.core.resolve.ResolveEngine.resolve(ResolveEngine.java:184)
    at org.apache.ivy.Ivy.resolve(Ivy.java:503)
    at org.apache.ivy.ant.IvyResolve.doExecute(IvyResolve.java:326)
    ... 20 more

Total time: 500 milliseconds

如果我删除冲突定义,则构建将按预期工作。下面是ivy.xml:

<ivy-module version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">

<info organisation="eu.inform" module="isac3-core" revision="1.0-snapshot"></info>
<configurations>
    <conf name="build" description="provide business logic for isac3"/>
    <conf name="test" extends="build" visibility="private" description="just for JUnit testing"/>
</configurations>
<publications>
    <artifact name="core-lib" type="jar" conf="build" ext="jar"/>
</publications>
<dependencies>

    <dependency org="org.apache.commons" name="commons-lang3" rev="3.1" conf="build->default"/>
    <dependency org="commons-codec" name="commons-codec" rev="1.6" conf="build->default"/>
    <dependency org="org.apache.mina" name="mina-core" rev="2.0.4" conf="build->default"/>
    <dependency org="org.apache.tika" name="tika-app" rev="1.1" conf="build->default"/>
    <!-- 
        Resolve conflict for SLF4J by selecting the latest compatible version:
        Apache tika comes packaged with slf4j 1.5.6, so we cannot exclude this dependency because it is part of the jar.
        Hibernate specifies a dependency to slf4j 1.6.1 by maven pom file.
     -->
    <conflict org="org.slf4j" rev="1.5.6"/>

    <dependency org="org.springframework" name="spring-aop" rev="3.1.1.RELEASE" conf="build->default"/>
    <dependency org="org.aspectj" name="aspectjweaver" rev="1.5.4" conf="build->default"/>
    <dependency org="org.springframework" name="spring-orm" rev="3.1.1.RELEASE" conf="build->default">
        <!-- don't include any ORM implementation since we defined the one we use -->
        <exclude org="org.eclipse.persistence" />
        <exclude org="toplink.essentials" />
        <exclude org="org.apache.ibatis" />
        <exclude org="org.apache.openjpa" />
        <exclude org="org.hibernate" />
    </dependency>
    <dependency org="org.hibernate" name="hibernate-core" rev="4.1.4.Final" conf="build->default"/>
    <dependency org="org.hibernate" name="hibernate-ehcache" rev="4.1.4.Final" conf="build->default"/>
    <dependency org="org.hibernate" name="hibernate-envers" rev="4.1.4.Final" conf="build->default"/>
    <dependency org="org.hibernate" name="hibernate-search-engine" rev="4.1.1.Final" conf="build->default"/>
    <dependency org="org.hibernate" name="hibernate-search-orm" rev="4.1.1.Final" conf="build->default"/>
    <dependency org="c3p0" name="c3p0" rev="0.9.1.2" conf="build->default"/>
    <dependency org="de.jollyday" name="jollyday" rev="0.4.6" conf="build->default"/>
    <dependency org="log4j" name="log4j" rev="1.2.17" conf="build->default"/>

    <!-- JDBC drivers -->
    <dependency org="net.sourceforge.jtds" name="jtds" rev="1.2.4" conf="build->default"/>
    <dependency org="com.microsoft" name="sqljdbc4" rev="4.0" conf="build->default"/>
    <dependency org="com.oracle" name="ojdbc6" rev="11.2.0.3" conf="build->default"/>

    <!-- dependencies solely for testing purposes (none-deployed) -->
    <dependency org="junit" name="junit" rev="4.10" conf="test->default"/>
</dependencies>

这就是蚂蚁build.xml(我省略了不必要的线条以保持它更紧凑):

<?xml version="1.0" encoding="ISO-8859-1"?>
<property name="src_base" location="src/main" />
<property name="src" location="${src_base}/java" />
<property name="config" location="${src_base}/config" />
<property name="resource" location="${src_base}/resource" />
<property name="build" location="build" />
<property name="buildSrc" location="${build}/main" />
<property name="lib" location="${build}/lib" />
<property name="dist" location="dist" />

<property name="distName" value="isac3-core-lib" />
<property name="distFileName" value="${distName}-${build.timestamp}.jar" />
<property name="zipFileName" value="${distName}-${build.timestamp}.zip" />

<property name="test.src" location="src/test/java" />
<property name="test.build" location="build/test" />
<property name="test.reports" location="build/report/test" />

<property name="ant.build.javac.source" value="1.7" />
<!-- Source-level version number -->
<property name="ant.build.javac.target" value="1.7" />
<!-- Class-compatibility version number -->
<property name="build.compiler" value="modern" />

...

<!-- ================================= 
      target: init
     ================================= -->
<target name="init" depends="clean">
    <!-- Create the time stamp -->
    <tstamp />
    <!-- Create the build directory structure used by compile -->
    <mkdir dir="${build}" />
    <mkdir dir="${buildSrc}" />
    <mkdir dir="${lib}" />
    <mkdir dir="${dist}" />
    <mkdir dir="${test.build}" />
    <mkdir dir="${test.reports}" />
</target>

<!-- ================================= 
      target: resolve              
     ================================= -->
<target name="resolve" depends="init" description="retrieve dependencies with ivy">
    <ivy:retrieve pattern="${lib}/[conf]/[artifact].[ext]" />
</target>

...

错误发生在ant目标“解决”中。Ivy似乎已加载,设置文件也按预期使用。但如前所述,我收到了语法错误。

以前有人看过这个,可以给我一个提示吗?

当做

塞巴斯蒂安(男子名)

共有1个答案

锺离声
2023-03-14

我抄袭了你的作品,我也有同样的错误,但不是用德语;)

无论如何,我尝试将冲突标签放在最后,它起作用了。所以现在它看起来像这样:

<dependencies>
    ... all dependencies
    <!-- dependencies solely for testing purposes (none-deployed) -->
    <dependency org="junit" name="junit" rev="4.10" conf="test->default"/>

    <conflict  org="org.slf4j" rev="1.5.6" />
</dependencies>

另外,这可能是复制粘贴错误,但您必须确保ivy.xml文件以

</ivy-module>.

让我们知道。

 类似资料:
  • 问题内容: 我在遵循MySQL语法指南时遇到语法错误。 我的查询是: 从逻辑上讲,这应该选择,但是我得到了 问题答案: 您的查询仅在存储过程/函数上下文中有效。参见那里以供参考。

  • 问题内容: 我最近在Java PreparedStatements中遇到了此问题。我有以下代码: 方法在哪里 但是,它总是抛出此错误: 当我以幼稚的方式执行“ …”时,不会发生此问题,但我希望以此方式进行。 任何帮助深表感谢。 更新 我尝试了社区的各种建议,例如 仍然出现错误信息。 问题答案: 解决问题的方法实际上非常简单,当您要调用PreparedStatement.executeQuery()

  • 我正在为我的数据库使用Sequelize(6.3.0)和sqlite3(4.2.0),并试图定义以下模型: 它应该在进程启动时定义,但我得到以下错误: 当然,每当我试图对此表执行任何操作时,都会出现以下错误: 我猜问题来自使用数组数据类型的“参与”和“赢家”行。 谢谢你的帮助

  • 问题内容: 我目前在我的Web应用程序中使用jQuery,Twitter Bootstrap和AngularJS。我一直在尝试进行路由,但是`Syntax error, unrecognized expression: 我需要在我的AngularJS路由中使用斜杠(即,并将在我的div中加载不同的内容)。可能是什么原因导致此错误? 问题答案: 我猜在指定目标时要多加斜杠。删除它们,它应该可以正常工

  • 我最近在Java PreparedStatements中遇到了这个问题。我有以下代码: 其中方法是 但是,它一直抛出这个错误: 当我以幼稚的方式做“...

  • 目前遇到此语法错误,错误发布在代码下方。 上面的代码,无法找出if语句上的语法错误。错误消息将很快粘贴为注释

  • 问题内容: 为什么Python在第9行的简单语句中给我一个语法错误? Python的版本是: 问题答案: 在Python 3中,print是一个函数,您需要像这样调用它。

  • 问题内容: 我正在尝试在Go中执行MERGE语句: 但是我得到了这个错误: 在MySQL中也是如此: 怎么了? 问题答案: 不支持,等效的是 插入…在重复的密钥更新上 尝试这个, 但请确保将其设置为或。