Replies: 1 comment
-
Remove @validated from your sample app controller and it will pass. # is used in evaluated expressions in Micronaut Framework 4. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
A controller has a customized annotation. In the annotation class, the following line prevents the controller to be created as a bean:
String foo() default "#{bar}";
Attached zip file is a maven project that reproduces the problem. I extended micronaut website created example by adding
SampleController.java: @controller annoatated controller that is annotated by @SampleAnnotation
SampleAnnotation.java: my customized annotation class, line 18 (String foo() default "#{bar}";) is failing the test
SampleTest.java: just to test calling the controller.
If you unzip the zip file, you will have creating-your-first-micronaut-app-maven-java folder.
Commands to build:
cd creating-your-first-micronaut-app-maven-java
mvn clean install -DskipTests
Command to test:
mvn test -Dtest= SampleTest
The test would fail:
However, If you change line 18 of SampleAnnotation.java to
String foo() default "!{bar}";
The test would pass. The difference is that at 18 of SampleAnnotation.java char # is changed to char !
I also noticed the following log in the successful test:
Above 3 line of log cannot be found in the failing test log. In other words, the repro shows that ! char in annotation class is preventing the controller class created as a bean.
Can you example why this happens? The same code works in micronaut 3 (using char #). Can you tell me how to fix this?
Beta Was this translation helpful? Give feedback.
All reactions