spring-boot

Disabling Spring Security headers does not work

时光怂恿深爱的人放手 提交于 2021-02-08 12:18:48
问题 I need to disable the cache control headers in my Spring Security conf. According to the documentation a simple http.headers.disable() should do it, but I still see the Cache-Control:no-cache, no-store, max-age=0, must-revalidate Expires:0 Pragma:no-cache headers in responses. My current security config is: http.antMatcher("/myPath/**") // "myPath" is of course not the real path .headers().disable() .authorizeRequests() // ... abbreviated .anyRequest().authenticated(); Things I've tried so

Configuring base package for component scan in Spring boot test

不打扰是莪最后的温柔 提交于 2021-02-08 12:17:58
问题 When I launch my test with the following annotations: package com.hello.package.p1; @RunWith(SpringRunner.class) @DataMongoTest @SpringBootTest public class ClassATest { @Autowired Service1 serivce1; //fqn = com.hello.package.p1.Service1 @Autowired Service2 serivce2; //fqn = com.hello.package.p2.Service2 ...} package com.hello.package.p1; @ActiveProfiles("test") @SpringBootConfiguration public class MongoTestConfig { ... } service1 will be injected. But service2 will not, since it is not in

DeadLetterPublishingRecoverer - Dead-letter publication failed with InvalidTopicException for name topic at TopicPartition ends with _ERR

不打扰是莪最后的温柔 提交于 2021-02-08 11:56:22
问题 I identified an error when I changed the DeadLetterPublishingRecoverer destionationResolver. When I use: private static final BiFunction<ConsumerRecord<?, ?>, Exception, TopicPartition> DESTINATION_RESOLVER = (cr, e) -> new TopicPartition(cr.topic() + ".ERR", cr.partition()); it works perfectly. However, if you use _ERR instead of .ERR, an error occurs: 2020-08-05 12:53:10,277 [kafka-producer-network-thread | producer-kafka-tx-group1.ABC_TEST_XPTO.0] WARN o.apache.kafka.clients.NetworkClient

Can not access deployed WAR file on Tomcat

笑着哭i 提交于 2021-02-08 11:55:52
问题 I have a Spring boot rest service project which works on my local machine. When I run the application as "Spring Boot App" I can access the rest service by going to http://127.0.0.1:8080/persons/all and it returns JSON as it's supposed to. I changed the pom.xml packaging to war, I then created a war by going to Run as -> Maven build in Spring tools suit. It creates a war file. When I upload the war file on http://myserverip:8080/manager/ I get no errors and it shows up under Applications The

HTTP and HTTPS with keycloack + spring

*爱你&永不变心* 提交于 2021-02-08 11:43:20
问题 I am trying to secure my application using keycloak. I use angular for my frontend and spring boot for my backend. Using only http, everything works fine, the problem is, if I want to use HTTPS along side HTTP, I am having a problem with the backend throwing an error like: o.k.a.BearerTokenRequestAuthenticator : Failed to verify token org.keycloak.common.VerificationException: Invalid token issuer. Expected 'http://myDomain/auth/realms/realmName', but was 'https://myDomain/auth/realms

CSRF token on a web page with multiple forms?

房东的猫 提交于 2021-02-08 11:41:48
问题 When CSRF is enabled and a web page has multiple forms, will all the forms have the same csrf token or each form has a unique csrf token? If this is framework dependent, then how does it work in the context of spring security? 回答1: CSRF is not associated with form or something but to associated with each request. Each individual request contains new csrf token. 来源: https://stackoverflow.com/questions/64422918/csrf-token-on-a-web-page-with-multiple-forms

How is @ConfigurationProperties-annotated classes detected automatically with @SpringBootApplication Annotation

…衆ロ難τιáo~ 提交于 2021-02-08 11:36:02
问题 I am learning Spring Boot and have a question with one example in the reference documentation. Following section of the documentation mentions 6. Using the @SpringBootApplication Annotation A single @SpringBootApplication annotation can be used to enable those three features, that is: @EnableAutoConfiguration: enable Spring Boot’s auto-configuration mechanism @ComponentScan: enable @Component scan on the package where the application is located (see the best practices) @Configuration: allow

Cannot convert String to MultipartFile

主宰稳场 提交于 2021-02-08 11:35:52
问题 Please help me to resolve my problem! I have bootstrap fileinput, files are included: <link href="/assets/css/fileinput/fileinput.css" rel="stylesheet" type="text/css"> <link href="/assets/css/fileinput/fileinput-rtl.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="/assets/js/fileinput/fileinput.js"></script> <script type="text/javascript" src="/assets/js/plugins/fileinput/piexif.js"></script> <script type="text/javascript" src="/assets/js/plugins/fileinput/sortable

Spring boot Non Controller Exceptions Handling - Centralized Exception Handling

一个人想着一个人 提交于 2021-02-08 11:02:37
问题 Is there a way to create a centralized exception handling mechanism in spring boot. I have a custom exception that I am throwing from multiple @Component classes and I would like it to be caught in one class/handler. This is NOT a REST API or Controller triggered call. I tried @ControllerAdvice with @ExceptionHandler . but no luck. Example below to shows what I am trying to achieve. Method Handle is not triggering. I am using spring boot v2.1.1 CustomException public class CustomException

Connecting and sending message between Spring WebSocket instances

柔情痞子 提交于 2021-02-08 10:48:32
问题 I have multiple instances using Spring Boot WebSocket (created following the first half of Spring's guide). I need them to connect to other instances at specific hostnames and ports and to be able to send messages over the websocket connection using STOMP protocol. How can I connect to my other services over websocket? How can I send messages using the STOMP protocol (preferably using the same marshalling/unmarshalling magic I get with received messages)? Things that don't answer my question: