简体   繁体   中英

How do I escape Java generics in Gmaven?

So you are writing a groovy script with some Java in it in GMaven. In between the source tags:

<source>

...some groovy code here

List<Chicken> = new ArrayList<>()

...some more groovy code here

</source>

Problem the < and the > look like XML tag components. Is there a way to escape those and if so, what is it?

Nest the code in CDATA.

Check out this: http://www.w3schools.com/xml/xml_cdata.asp

Yes, you can escape them with XML/HTML entities

List&lt;Chicken&gt; = new ArrayList&lt;&gt;()

Reference :
List of XML and HTML character entity references

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM