spring-el

How do I use Spring Expression Language for an Array in an annotation with Scala

别来无恙 提交于 2020-02-08 02:32:21
问题 I have a simple Scala project that looks like this... @Configuration public class CommonConfiguration{ ... @Value("${spring.kafka.topic}") public String topic; ... } @Service class KafkaService @Autowired()(producer: KafkaTemplate[String, Array[Byte]], config: CommonConfiguration){ def sendMessage(msg: String): Unit = { println(s"Writing the message $msg ${config.topic}") producer.send(config.topic, msg.getBytes()); } @KafkaListener(id="test", topics="#{'${spring.kafka.topic}'.split(',')}")

How do I use Spring Expression Language for an Array in an annotation with Scala

♀尐吖头ヾ 提交于 2020-02-08 02:32:12
问题 I have a simple Scala project that looks like this... @Configuration public class CommonConfiguration{ ... @Value("${spring.kafka.topic}") public String topic; ... } @Service class KafkaService @Autowired()(producer: KafkaTemplate[String, Array[Byte]], config: CommonConfiguration){ def sendMessage(msg: String): Unit = { println(s"Writing the message $msg ${config.topic}") producer.send(config.topic, msg.getBytes()); } @KafkaListener(id="test", topics="#{'${spring.kafka.topic}'.split(',')}")

How do I set JobParameters in spring batch with spring-boot

此生再无相见时 提交于 2020-01-31 22:21:18
问题 I followed the guide at http://spring.io/guides/gs/batch-processing/ but it describes a job with no configurable parameters. I'm using Maven to build my project. I'm porting an existing job that I have defined in XML and would like to pass-in the jobParameters through the command. I tried the following : @Configuration @EnableBatchProcessing public class MyBatchConfiguration { // other beans ommited @Bean public Resource destFile(@Value("#{jobParameters[dest]}") String dest) { return new

Need data from database for use in SpEL method level security

风格不统一 提交于 2020-01-16 19:13:46
问题 I would like to use SpEL to handle method level security. I run into an issue where the data passed to the method is not enough to determine if a user has access. Here is an example @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("@securityService.isAllowedAccessByCurrentUser(#.id)") public void delete(@PathVariable("id") final Long id) { service.delete(id); } Here, the id variable is the ID of some object. To get the owner

String.replace() returns unwanted string

别等时光非礼了梦想. 提交于 2020-01-13 04:56:09
问题 I'm working on a piece of code where I've to split a string into individual parts and replace them. The basic logic flow of my code is, there's a string that contains a formula. The numbers below on the LHS, i.e 1, 2 and 3 are ids of different objects. Once I split them, I'd use these ids, get the respective value and replace the ids in the below String with its respective values. The string that I have is as follow - String str = "(1+2+3)>100"; I've used the following code for splitting the

How to filter a collection in thymeleaf th:each using another property in comparison

我与影子孤独终老i 提交于 2020-01-12 08:02:43
问题 I am trying to filter the collection using Thymeleaf by following the example in the following url. "Projection & selection on collection" section. http://doanduyhai.wordpress.com/2012/04/14/spring-mvc-part-iv-thymeleaf-advanced-usage/ <tr th:each="artist,rowStat : ${listArtits.?[alive == true]}"> ... </tr> However I would like to use another property instead of fixed value (true/false). For example <tr th:each="artist,rowStat : ${listArtits.?[played > playedCountReq]}"> ... </tr> where as

Picking up Tomcat's Context.xml parameters via SpEL

99封情书 提交于 2020-01-04 06:28:12
问题 Deploying war to Apache Tomcat 8 the following way. Placing myApp.xml under $CATALINA_HOME/conf/[enginename]/[hostname]/ with the following contents: <Context> <Parameter name="myApp_configs" value="file:/the/path/to/configs/folder" type="java.lang.String" override="false"/> </Context> B.t.w. I do not place any kind of Context.xml into war . Then copying myApp.war to $CATALINA_HOME/webapps This is my web.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems,

Spring.NET Expression that References an Object Definition

南笙酒味 提交于 2020-01-04 06:06:01
问题 I'm trying to reference another object I've defined in a Spring config file from within an expression. Specifically, I'm trying to populate a property with the value of an expression where I call a method and then a property on the object returned from that method. I've tried the following (names have been changed): <property name="NullableIntProperty" expression="#{Some.Object.Id}.Get().NullableIntValue"/> where Some.Object.Id is a reference to another object I have defined in a config file

Spring.NET Expression that References an Object Definition

99封情书 提交于 2020-01-04 06:05:04
问题 I'm trying to reference another object I've defined in a Spring config file from within an expression. Specifically, I'm trying to populate a property with the value of an expression where I call a method and then a property on the object returned from that method. I've tried the following (names have been changed): <property name="NullableIntProperty" expression="#{Some.Object.Id}.Get().NullableIntValue"/> where Some.Object.Id is a reference to another object I have defined in a config file

Spring 3.1 cache - how to use the returned value in the SpEL

99封情书 提交于 2020-01-01 06:55:29
问题 I am trying to make an eviction of an entry in a Spring-managed cache (Spring 3.1 abstraction). I need to refer to the returned value of the method in the SpEL of the "key" property in the annotation: /* (How to refer to the 'T' returned value in the "KEY_ID"?) */ @Caching(evict = { @CacheEvict(value = CACHE_BY_ID, key = KEY_ID) }) public T delete(AppID appID, UserID userID) throws UserNotFoundException { return inner.delete(appID, userID); } Is there any way to do this? 回答1: It doesn't seem