What is the right way to send a client certificate with every request made by the resttemplate in spring?

Here is example how to do this using RestTemplate and Apache HttpClient You should define your own RestTemplate with configured SSL context: @Bean public RestTemplate restTemplate(RestTemplateBuilder builder) throws Exception { char[] password = “password”.toCharArray(); SSLContext sslContext = SSLContextBuilder.create() .loadKeyMaterial(keyStore(“classpath:cert.jks”, password), password) .loadTrustMaterial(null, new TrustSelfSignedStrategy()).build(); HttpClient client = HttpClients.custom().setSSLContext(sslContext).build(); return builder .requestFactory(new HttpComponentsClientHttpRequestFactory(client)) .build(); } private … Read more

Where do I put my XML beans in a Spring Boot application?

As long as you’re starting with a base @Configuration class to begin with, which it maybe sounds like you are with @SpringBootApplication, you can use the @ImportResource annotation to include an XML configuration file as well. @SpringBootApplication @ImportResource(“classpath:spring-sftp-config.xml”) public class SpringConfiguration { // }

Jackson’s @JsonView, @JsonFilter and Spring

This issue is solved! Follow this Add support for Jackson serialization views Spring MVC now supports Jackon’s serialization views for rendering different subsets of the same POJO from different controller methods (e.g. detailed page vs summary view). Issue: SPR-7156 This is the SPR-7156. Status: Resolved Description Jackson’s JSONView annotation allows the developer to control which … Read more

Spring Request scope vs java thread-local

If we consider the traditional Java approach the answer can be deducted from the quote bellow as being much slower: Because reflection involves types that are dynamically resolved, certain Java virtual machine optimizations can not be performed. Consequently, reflective operations have slower performance than their non-reflective counterparts, and should be avoided in sections of code … Read more

Spring Data Join with Specifications

EDIT: Ok, I did quite a mess here, but I hope this time I’m closer to the right answer. Consider (id’s are auto-generated like 1 for John etc.): INSERT INTO some_user (name) VALUES (‘John’); INSERT INTO some_user (name) VALUES (‘Ariel’); INSERT INTO some_user (name) VALUES (‘Brian’); INSERT INTO some_user (name) VALUES (‘Kelly’); INSERT INTO some_user … Read more

Spring webflux and reading from database

One option would be to use alternative SQL clients that are fully non-blocking. Some examples include: https://github.com/mauricio/postgresql-async or https://github.com/finagle/roc. Of course, none of these drivers is officially supported by database vendors yet. Also, functionality is way much less attractive comparing to mature JDBC-based abstractions such as Hibernate or jOOQ. The alternative idea came to me … Read more

Why is my Spring 3 Validator Validating Everything on the Model?

I guess this behaviour is not covered in the documentation well. The problem is caused by the following: By default, @InitBinder-annotated method is called for each non-primitive model attribute, both incoming and outcoming (the purpose of calling it for outcoming attibutes is to allow you to register custom PropertyEditors, which are used by form tags … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)