简体   繁体   中英

Prevent Maven from removing $ (dollar sign) from archetype resources?

I have a Maven archetype with some .java files. Inside them I perform some tests that need to use $ to evaluate json with json-path, eg:

.andExpect(jsonPath("$.id", is(1)))

When I generate the project with mvn archetype:generate, the dollar is no longer present:

.andExpect(jsonPath(".id", is(1)))

Is there any way to tell Maven not to remove that $?

I've tried escaping in different ways: \\$ - $$ - \\$...without success.

I've noticed that the $ sign is only removed when it's followed by a dot and some text :

  • $$ stays $$
  • $. stays $
  • $.text changes into .text

you can also use this syntax:

#set( $symbol_dollar = '$' )

.andExpect(jsonPath("${symbol_dollar}.id", is(1))

This is somewhat of a workaround, but you can do:

.andExpect(jsonPath("$"+".id", is(1)))

to prevent maven from removing it.

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