I have resource plugin configuration in pom.xml in CLI NON-SPRING app:
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
calling mvn resources:resources
successfully replaces all ${variables}.
The project got into state, that it would really genefit from inversion of control, so I'd like to throw spring into action here. Step one, add spring parent:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<!-- <version>2.7.7</version>-->
<version>2.6.6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
not the same command won't substitute variables, resource filtering does not work.
What am I missing?
I know that spring defines some plugins, and if one want to redefine them, he needs to use same ID for example, but I cannot find the root-problem here. (and note: yes, I know I can avoid referencing spring via parent or use weld/cdi instead, but atm I'd like to get working spring with defined parent)
CodePudding user response:
Remembered the cause thanks to writing to stack overflow used a rubber duck (sorry).
It's caused by that variable pattern is different to avoid conflict between spring and maven variables. Spring redefined variable placeholders. What was: ${project.version}
before is now @project.version@
or whatever you define, but you cannot use ${}
otherwise spring will 'erase' all variables spring should substitute.
Sorry for pointless question. Keeping it, maybe it will help someone in future.
CodePudding user response:
If you are only adding spring for IoC then you don't need to add the whole package. I thing you can get away only with:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.4.0</version>
</dependency>
Also the dependency that you have added is used for spring boot projects.