Questions tagged [spring-expression-language]

34 questions
4
votes
1 answer

How do I unit test spring security @PreAuthorize custom expression

@PostMapping @ResponseStatus(HttpStatus.CREATED) @PreAuthorize("@messageSecurityService.isAuthorized(#userAuthentication)") public void sendMessage(@AuthenticationPrincipal UserAuthentication userAuthentication, …
3
votes
1 answer

Cosmos DB Container Name with EL not resolving in SpringBootTest

@SpringBootTest(properties = {"spring.profiles.active=build"}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)` @TestPropertySource(value =…
3
votes
0 answers

Spring java 11 getting spel issue EL1005E: Type cannot be found

Getting below issue post upgrading Spring boot app to Java 11, this was working fine even on 2.1 spring boot on Jdk 8 Jdk : Correto 11 Spring boot : 2.2.13.RELEASE Spring Integration : 5.2.11.RELEASE Code : …
3
votes
1 answer

Using Java classes inside Spring @Value('#{SPEL})

I would like to parse the property value into an custom Object. Example; i have application.properties; say rules.peakHours.weekday.morning.start=10:15:45 And would like to convert that property into java LocalTime object. @Configuration public…
Kanagavelu Sugumar
  • 18,766
  • 20
  • 94
  • 101
2
votes
3 answers

How to add an object without a constructor to a list using Spring Expression Language

I want to add a BigDecimal to a list using Spring Expression Language. public class SpelTest { public List values; StandardEvaluationContext context; SpelExpressionParser parser; @Before public void setup() { …
2
votes
3 answers

Using Spring expression language to assert if a property (with comma separated values) loaded from a properties file, contains "value"

I have the following problem, I have a certain configuration class in spring boot which contains beans, which I would like to be created only if a certain property which has a list of values, contains a certain value. now the configuration class…
Carlos Luis
  • 213
  • 2
  • 17
2
votes
1 answer

Filter integer list in Thymeleaf

I am learning about Thymeleaf in Spring, and I am struggling with list fitlering. The official Tutorial: Using Thymeleaf does not talk about collection filtering and projection, but I found out that Thymeleaf on Spring uses the Spring Expression…
1
vote
1 answer

Configure map data in Helm chart values.yaml file

I'm trying to deploy my Spring Boot application in Minikube using Helm charts. I have a configuration class where I map all the @value variables. If keep my map value in application.yaml or applicationConfig.yaml file…
1
vote
1 answer

Get property programmatically and evaluate it with SPEL

I am trying to mimic the @Value annotation programmatically by retrieving a property from the properties file using Environment and then evaluate the expression using SpelExpressionParser. Here is a code snippet: @Service @Slf4j public class Test { …
1
vote
1 answer

Spring JPA: batch insert query with collections using SpEL possible?

I want to create a an insert query on a repository using the following function void insertValues(Iterable keys) The query must insert multiple rows, but only the primary key changes, the rest are constants; I tried with the following…
Alex Sim
  • 403
  • 3
  • 16
1
vote
1 answer

spring integration spel expression to extract fields from message payload

Not able to get my head over SPEL for Message payloads. I want to extract data from certain fields of my message payload which is essentially the following JSON converted to Map and passed to a @Transformer { …
1
vote
3 answers

Using a request header value in @PreAuthorize

Is it possible to use a request header value in @PreAuthorize? In my app, all requests have a custom header included which I need to use in conjunction with the user role to determine whether or not they should be allowed to access the…
1
vote
0 answers

Spring expression fails after upgrade to SpringBoot 2.2

I had an application which was on SpringBoot 1.5.9. I recently upgraded to SpringBoot 2.2. I had a bunch of issues which I fixed, and now the app starts up without errors. However, I have a @PreAuthorize on my controller methods which seems to be…
starman1979
  • 974
  • 4
  • 12
  • 33
1
vote
1 answer

To use expression language to get values

My expression is :#age*10 And I assigned a value of 15.6 to age The result of this is 156.0 In fact the final result I want to get is:156 I can do it in the code, but how to do it by modifying the expression. thanks
1
vote
0 answers

How to force Thymeleaf to show attribute with empty value?

I'm using Thymeleaf 3.0.11 with Spring 4.3.22, no Boot. Have this code: It works fine when the userId has a value. Then the output is, for example:
k6ps
  • 359
  • 4
  • 11
1
2 3