Maven原型-由于冒号而导致的速度错误 [英] Maven archetype - Velocity error because of a colon
本文介绍了Maven原型-由于冒号而导致的速度错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
由于其中一个资源中存在冒号(':'),因此我无法创建Maven原型.我有一个包含该符号的Spring XML:
I am having trouble creating a Maven archetype because of the presence of a colon character (':') in one of the resources. I have a Spring XML that includes that symbol:
<property name="maxSize" value="${ws.client.pool.maxSize:5}"/>
启动原型时出现此错误:
When launching the archetype I get this error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.2:generate
(default-cli) on project standalone-pom:
org.apache.maven.archetype.exception.ArchetypeGenerationFailure: Error merging velocity templates:
Encountered ":5}\"/>\n\t</bean>\n\t\n\t<bean id=\"fooServiceClient\" class=\"org.springframework.aop.framework.ProxyFactoryBean\">\n\t <property name=\"targetSource\" ref=\"fooServiceClientPoolTargetSource\"/>\n\t</bean>\n\n</beans>\n"
at line 15, column 69 of archetype-resources/src/main/resources/spring/library.ws-client.xml
[ERROR] Was expecting one of:
[ERROR] "}" ...
[ERROR] <DOT> ...
[ERROR] "(" ...
[ERROR] -> [Help 1]
[ERROR]
我尝试在原型的pom中配置转义字符:
I tried configuring a escape character in the archetype's pom:
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-archetype-plugin</artifactId>
<version>2.0</version>
</plugin>
<!-- Resources configuration -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<configuration>
<encoding>UTF-8</encoding>
<escapeString>\</escapeString>
</configuration>
</plugin>
</plugins>
</pluginManagement>
但是它仍然不起作用.在这种情况下:
However it still doesn't work. In this case:
<property name="maxSize" value="${ws.client.pool.maxSize\:5}"/>
错误如下:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.2:generate
(default-cli) on project standalone-pom: org.apache.maven.archetype.exception.ArchetypeGenerationFailure:
Error merging velocity templates:
Encountered "\\" at line 15, column 69 of archetype-resources/src/main/resources/spring/library.ws-client.xml
[ERROR] Was expecting one of:
[ERROR] "}" ...
[ERROR] <DOT> ...
[ERROR] "(" ...
[ERROR] -> [Help 1]
[ERROR]
关于如何逃避结肠的任何想法?
Any idea on how to escape that colon?
推荐答案
我制定了一个基于Velocity变量($ maxSize)的解决方案:
I worked out a solution based on a Velocity variable ($maxSize):
#set( $maxSize = '${ws.client.pool.maxSize:5}' )
<bean id="fooServiceClientPoolTargetSource" class="org.springframework.aop.target.CommonsPoolTargetSource">
<property name="targetBeanName" value="fooServiceClientTarget"/>
<property name="maxSize" value="$maxSize"/>
这篇关于Maven原型-由于冒号而导致的速度错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文