Maven原型 – 由于冒号而导致速度错误

我在创建Maven原型时遇到了麻烦,因为其中一个资源中存在冒号字符(’:’)。 我有一个包含该符号的Spring XML:

 

启动原型时,我收到此错误:

 [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\n\t\n\t\n\t \n\t\n\n\n" at line 15, column 69 of archetype-resources/src/main/resources/spring/library.ws-client.xml [ERROR] Was expecting one of: [ERROR] "}" ... [ERROR]  ... [ERROR] "(" ... [ERROR] -> [Help 1] [ERROR] 

我尝试在原型的pom中配置转义字符:

     maven-archetype-plugin 2.0    org.apache.maven.plugins maven-resources-plugin 2.5  UTF-8 \     

但它仍然无效。 在这种情况下:

  

错误如下:

 [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]  ... [ERROR] "(" ... [ERROR] -> [Help 1] [ERROR] 

关于如何逃脱结肠的任何想法?

与可选属性的以下Spring注入代码有相同的错误:

 @Value("${hostname:}") private String hostName; 

解决方案:

 #set( $dollar = '$' ) @Value("${dollar}{hostname:}") private String hostName; 

关键步骤是在{花括号}中包含对$ constant的引用

我根据Velocity变量($ maxSize)制定了一个解决方案:

 #set( $maxSize = '${ws.client.pool.maxSize:5}' )