Spring

Postman utf-8 encoding issue when charset=utf-8 is not provided by server

女生的网名这么多〃 提交于 2021-02-10 08:38:16
问题 Spring deprecated APPLICATION_JSON_UTF8 ( application/json;charset=UTF-8 ) annotation as they said: /** * A String equivalent of {@link MediaType#APPLICATION_JSON_UTF8}. * @deprecated as of 5.2 in favor of {@link #APPLICATION_JSON_VALUE} * since major browsers like Chrome * <a href="https://bugs.chromium.org/p/chromium/issues/detail?id=438464"> * now comply with the specification</a> and interpret correctly UTF-8 special * characters without requiring a {@code charset=UTF-8} parameter. */

Spring AOP原理(续)

南楼画角 提交于 2021-02-10 07:58:30
十二、AOP 1. 说出Spring的通知类型有哪些? spring共提供了五种类型的通知: 通知类型 接口 描述 Around 环绕通知 org.aopalliance.intercept.MethodInterceptor 拦截对目标方法调用 Before 前置通知 org.springframework.aop.MethodBeforeAdvice 在目标方法调用前调用 After 后置通知 org.springframework.aop.AfterReturningAdvice 在目标方法调用后调用 Throws 异常通知 org.springframework.aop.ThrowsAdvice 当目标方法抛出异常时调用 前置通知[Before advice]:在连接点前面执行,前置通知不会影响连接点的执行,除非此处抛出异常。 正常返回通知[After returning advice]:在连接点正常执行完成后执行,如果连接点抛出异常,则不会执行。 异常返回通知[After throwing advice]:在连接点抛出异常后执行。 返回通知[After (finally) advice]:在连接点执行完成后执行,不管是正常执行完成,还是抛出异常,都会执行返回通知中的内容。 环绕通知[Around advice]:环绕通知围绕在连接点前后,比如一个方法调用的前后

How to set placeholder values in properties file in spring

不问归期 提交于 2021-02-10 07:40:43
问题 Below is application.properties file app.not.found=app with {0} name can not be found. How to replace {0} with some value in spring? I am using below code to read properties file values. env.getProperty("app.not.found") but not getting how to set placeholder values. 回答1: Use MessageFormat.format(String pattern, Object ... arguments) . It accepts an array in second parameter, which will replace 0, 1 , 2 ... sequentially. MessageFormat.format(env.getProperty("app.not.found"), obj) obj will

SpEL cannot handle 'é'?

こ雲淡風輕ζ 提交于 2021-02-10 07:35:33
问题 I'm a french so I put some é è ê ô û in my code. (and I don't speek english very well). I've a method like that in a class Formulaires : public static Formulaire exposé() And in a config spring xml file, I try : <entry key="intro" value="#{T(com.myproject.Formulaires).exposé()}"/> But Spring says : Caused by: java.lang.IllegalStateException: Cannot handle (233) 'é' at org.springframework.expression.spel.standard.Tokenizer.process(Tokenizer.java:193) at org.springframework.expression.spel

SpEL cannot handle 'é'?

冷暖自知 提交于 2021-02-10 07:35:12
问题 I'm a french so I put some é è ê ô û in my code. (and I don't speek english very well). I've a method like that in a class Formulaires : public static Formulaire exposé() And in a config spring xml file, I try : <entry key="intro" value="#{T(com.myproject.Formulaires).exposé()}"/> But Spring says : Caused by: java.lang.IllegalStateException: Cannot handle (233) 'é' at org.springframework.expression.spel.standard.Tokenizer.process(Tokenizer.java:193) at org.springframework.expression.spel

Spring IOC & AOP

故事扮演 提交于 2021-02-10 07:26:50
IOC,控制反转,就是将对象的创建,销毁交由容器来控制,DI,依赖注入,对象的引用由容器来帮忙完成。 AOP面向切面编程,关注的是公共功能,将那一部分代码封装在一起,在运行时,由容器动态织入。如,事务管理,权限控制,日志记录,异常处理。AOP的概念,Pointcut(切点,表达式,用来限制连接点),Join Point(连接点,被拦截的方法),Advice(通知,分为前置通知,环绕通知,后置通知,后置通知又分为正常执行后通知和异常执行后通知),引入(允许对被通知的对象引入新的属性或者方法,实现新功能的同时不影响原来的对象),织入(将通知织入到连接点的过程) https://www.cnblogs.com/boywwj/p/7502185.html 来源: oschina 链接: https://my.oschina.net/u/2308196/blog/3020834

Allow Camel context to run forever

一笑奈何 提交于 2021-02-10 07:17:27
问题 I am using camel-spring jar for springCamelContext. When I start the camel context , it run for 5 minutes (Default time). I can make my thread sleep for some specific time i.e. try { camelContext.start(); Thread.sleep(50 * 60 * 1000); camelContext.stop(); } catch (Exception e) { e.printStackTrace(); } BUT I want is my camelContext to run FOREVER because this application is going to be deployed and It will be listening for messages from KAFKA server. I know there is a class org.apache.camel

Spring Boot error in setting up SSL connection

∥☆過路亽.° 提交于 2021-02-10 07:10:00
问题 I am trying to connect my Spring Boot application to a PostGresSql database. But every time I get error in setting up SSL connection error. My application.properties file is given below:- server.port=8443 spring.datasource.url=jdbc:postgresql://localhost:5432/testdb spring.datasource.username=postgres spring.datasource.password=1234 spring.datasource.driver-class-name=org.postgresql.Driver spring.datasource.dbcp2.test-while-idle=true server.ssl.key-alias=selfsigned_localhost_sslserver server

How to send MultiPart and RequestBody together In Spring-boot 2.x

北城余情 提交于 2021-02-10 06:57:32
问题 I'm implementing microservices in Spring-boot. I try to send @RequestBody with a MultipartFile together. I refereed some questions in stackoverflow, but nothing helps me. Video class @Data public class Video{ @id ObjectId _id; private String title; private String description; List<String> tags; } Method @PostMapping(RequestUrl.VIDEO_ADD_VIDEO) public ResponseEntity<BulkWriteResult> addNewVideoToCategory( @RequestBody Video video @RequestPart MultipartFile file) { // some logics } In

Spring Boot OAuth2, with Tomcat and nginx get error ERR_TOO_MANY_REDIRECTS after authenticate

泄露秘密 提交于 2021-02-10 06:52:37
问题 I have a Spring Boot application, it use OAuth2 authentication from WSO2 Identity Server. When I run the aplication on Spring Tool Suit, it works, so i can sing in and use my web site. But when I run my application on Tomcat(9.0), I try access a page, and redirect to login page, and when i try to sign in, I get the error ERR_TOO_MANY_REDIRECTS Error Example: When my spring boot app is runing on Tomcat, and I try to access the html page: https://domain/chat/example.html if the user was not