1,309 questions
0
votes
0
answers
45
views
CDS based Audit Logging in CAP
We are trying to perform audit logging for the user details when changed using the annotation mentioned below.
But when the patch call is triggered for the entity, the changes are not logged in the ...
0
votes
0
answers
64
views
How to migrate legacy Spring MVC Form Controllers (`AbstractFormController`) to annotation-based controllers in newer Spring versions?
I’m upgrading a legacy Java Spring MVC application.
Current setup:
Java 1.8 (recently upgraded from Java 1.7)
Spring 3.2.18
Uses the old AbstractFormController, SimpleFormController, and XML-based ...
0
votes
1
answer
177
views
OpenAPI Generator 7.9.0 generates methods with _0 as suffix. How to work around that issue?
Why does OpenAPI Generator generate some of the methods with _<Number>, even though operation IDs in my spec are unique?
Is there any workaround (by using properties) in OpenAPI 7.9.0? There is ...
0
votes
0
answers
63
views
Spring does not recognize @PreAuthorize inside custom annotation
If I use the just standard way @PreAuthorize("hasRole(@roleProperties.getSelect()) or hasRole(@roleProperties.getOtherSelect())") over my RestController methods, the @PreAuthorize works ...
0
votes
0
answers
69
views
What is an annotation in Spring Boot [duplicate]
I have been trying to find a simple definition of an annotation is Spring Boot, specifically:
a) What it does
b) When / how you would use it
While I am using annotations in my code such as @Repository ...
1
vote
1
answer
121
views
AOP @Aspect not triggered in @SpringBootTest
I'm using spring-boot 3.4.2.
I want to use AOP aspects in order to modify annotations that I use in a spring boot test.
However my @Around method is not triggered during test execution.
If I annotate ...
1
vote
1
answer
121
views
SpringAOP JoinPoint Arguments Parser with SpEL Expression
I'm creating an annotation, like below
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Annotation {
String template();
String[] parameters() default {};
}
I ...
0
votes
0
answers
180
views
How to resolve lombok's error under intellij idea in the spring boot project?
I'm working on a simple Spring Boot project where I have used sping web and lombok dependency. In the model class I have used lombok annotation instead of creating constractor, getter and setter ...
-1
votes
2
answers
50
views
Access message parameters in controller advice passed from Custom validator
I have a custom validator and need to include message parameters to construct the error message dynamically.
public class DescriptionLengthValidator
implements ConstraintValidator<...
3
votes
1
answer
50
views
Spring initializing the @Value annotation property from a static field
Having the following code:
public class Constants {
public static final String X = "-";
}
And in another class
@Value("${some.property:Constants.X")
private String separator;
...
0
votes
1
answer
54
views
Changing value passed into custom @Qualifier
Is there a way to change the value passed to a custom @Qualifier, and pass it to the delegating @Qualifier?
I understand that we can create custom qualifiers by
@Qualifier
@Target({ ElementType.FIELD, ...
-1
votes
1
answer
62
views
Why spring is not able to get the beans when I have given @ComponentScan?
I am trying to understand this question, suppose I am having spring without spring boot, I am creating a new context but without passing the configuration class like below
@ComponentScan("com....
-3
votes
1
answer
54
views
Spring Boot @Value not fetching values [closed]
The @Value annotation is not fetching data from application.properties
Please check the code in the below repository
https://github.com/dev1ad/props
The @Value in WebController works whereas the @...
0
votes
1
answer
274
views
How to debug/trace Spring PreAuthorize annotation
I have spring boot application. I am trying to follow the official spring tutorial from here https://github.com/spring-attic/tut-react-and-spring-data-rest/
or specifically this class:
https://github....
1
vote
0
answers
136
views
Shortcut for annotations in Spring [duplicate]
I have several methods with quite similar annotations. I want to extract common parts.
For example I have this:
@ApiResponse(
description = "Some description",
...
0
votes
1
answer
64
views
Spring doesn't scan classes annotated with @Component/@Service etc
I have an application in java 21 that is a minecraft spigot plugin. I use spring framework 6.1.10. These are my dependencies:
<dependency>
<groupId>org.springframework&...
1
vote
1
answer
80
views
Spring UnsatisfiedDependencyException, Error creating bean with name
I have my security config class like this
@Configuration
@EnableWebSecurity
@ComponentScan
@EnableJpaRepositories
public class SecurityConfig {
@Value("${cors-allow-origin.url}")
...
0
votes
1
answer
587
views
Why does my @Pattern @Size annotations don't work with @Valid (In Spring Boot v.3)?
I'm trying to learn Java using Spring Boot v.3 and to manage a FAKE database with it. This afternoon I was trying to implement some "constraints" for the username and password input via @/...
0
votes
1
answer
99
views
404 not found postman
i run my spring application and it's showing no errors, here's my controller
package com.testAOP.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework....
0
votes
1
answer
213
views
Why is AspectJ Logging Not Triggering When Aspect and Interface are Annotated?
I'm looking for a way to get logging around methods.
So I've started looking at examples of Spring-AOP and AspectJ.
However, none of these seem to actually work, or at least are missing pieces in ...
0
votes
1
answer
44
views
Is there a way to remove leading and trailing substrings without custom code?
Can you remove leading-and-lagging characters-and-substrings from a string without using RegEx-and/or-Custom-Code?
For example, I want to remove leading https:// and lagging / (backslashes).
I can ...
0
votes
0
answers
131
views
Why is the Spring Boot new version like this? The old version doesn't.Annotation-specified bean name 'application' for bean class [xxx.Application]
Why is the Spring Boot new version like this? The old version doesn't.Annotation-specified bean name 'application' for bean class [xxx.Application]
This is a multi-module demo.
Annotation-specified ...
2
votes
3
answers
271
views
@DateTimeFormat not converting date while sending response
I have a Spring MVC application (Without Boot). I am using Spring MVC 6.
I am trying to learn @ResponseBody tag and I created an object of my bean class in the controller and sending it in the ...
0
votes
1
answer
70
views
Why I'm getting error while running Spring Boot application that define bean of type 'com.exam.repo.UserRepository' in your configuration?
package com.exam.examserver;
import java.util.HashSet;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import ...
0
votes
0
answers
67
views
Custom annotation for date validation in a pathVariable in the controller is working incorrectly
There is an annotation being used in a dto to validate a DateTime variable, which is working correctly, returning a 400. However, when I try to use this annotation in the controller, it returns an ...
4
votes
1
answer
752
views
Implementing a custom annotation with readable attributes in Spring Configuration (test)
I am familiar with composite annotations. However, it seems they are not enough for my specific need even after some research.
General case
I want to create an annotation for testing that, put on a ...
0
votes
1
answer
116
views
Spring method security SpEL annotations always give 401 after upgrading Spring-boot to 3.2.2
When upgrading from spring-boot 3.2.1 to 3.2.2 one the following SPEL security annotations stopped working. Now, it always gives a 401. Apparently, Spring security version did not upgrade between the ...
1
vote
1
answer
276
views
Spring @Value default fails to evaluate expression
I need to set up thread pool size for scheduled tasks based on either specified property or available resources.
So, I wrote the following code:
@EnableScheduling
@Configuration
public class ...
-2
votes
2
answers
1k
views
Is it possible to name a Spring configuration class by passing a name to the @Configuration annotation?
I am building a Kafka streaming app (Java/Spring) and have a configuration class that uses @Value to assign values to the properties there as usual. In the configuration class is a method that sets ...
0
votes
1
answer
428
views
How to apply @Table annotation with different names based on some Spring condition?
Problem: Reserved keywords
I have an entity class named User for historical reasons which Hibernate calculates a table name of user by default. That name is a reserved SQL keyword and breaks without ...
1
vote
0
answers
427
views
Scraping of metrics isn't working on spring boot with Micrometer annotations @Timed and @Counted with a prometheus
I am trying to design an application that will show metrics about it's health and other custom metrics, like how long each function runs and how many times etc. I am on spring boot 2.7.1. I want to ...
3
votes
2
answers
5k
views
why prefering @TestConfiguration than @Configuration in src/test
i currently study more in deep the @TestConfiguration
and i wonder why using this combo..
@TestConfiguration
public class TestConfig {
// some bean definitions
and then using
@...
0
votes
1
answer
60
views
Write-then-read in Spring Transactional
What is the behavior for Spring's Transactional when writing-then-reading?
Let's say I have a method annotated with @Transactional, and the first thing it does is modify an object. Then, I read that ...
0
votes
1
answer
459
views
Issue with @Aggregation Annotation in Spring Data MongoDB Repository
I am encountering an issue with the @Aggregation annotation in a Spring Data MongoDB repository in my Spring Boot application. While the @Query annotation works as expected, using @Aggregation results ...
1
vote
0
answers
44
views
Can I simplify spring configuration file beans by combining the annotations onto one method?
I m making a @Configuration class that is to just provide the names of topics and queues I want to publish/subscribe to using JMS. The config file looks something like the following but repeated 10+ ...
0
votes
1
answer
554
views
How to inject Spring beans into a JUnit Jupiter ExecutionCondition
I have custom Interface "Platform" with @ExtendWith annotation and Class which implements ExecutionCondition.
@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType....
-1
votes
1
answer
93
views
cant understand @joincolumn(name="user_id")
i have created two seperated class in entity,
varibale declared in user class is :
private Long id;
private String name;
variable declared in book class is:
private Long id;
private String title;
...
0
votes
1
answer
432
views
@Email annotation not working in springboot application
I have a getMapping controller which accepts emailId and Set as input.
I want to have a validation check for Non empty/blank values and email id validation, below is the sample code. @Email validation ...
0
votes
1
answer
63
views
Accessing Bean with same name
When I have two beans with the same name, the first one I defined always runs when I try to use them. How can I make the second bean run instead? I even tried using the @Primary annotation, but it ...
1
vote
0
answers
269
views
How does Spring parse Annotations to load the Application Context
I need help understanding how a spring boot application reads annotations in order to configure the application context. Let me give an example of what is confusing me:
I have a spring boot ...
0
votes
1
answer
397
views
Could not resolve placeholder 'spring.jpa.hibernate.ddl-auto' in value "${spring.jpa.hibernate.ddl-auto}" - Spring Framework (Java 17)
I'm encountering an issue with my Spring application in Java 17, and I'm getting the error message "Could not resolve placeholder 'spring.jpa.hibernate.ddl-auto' in value "${spring.jpa....
0
votes
1
answer
54
views
Can the same Custom Annotation be used to validate T and List<T>?
Good morning,
I have the following custom annotation in Java (Spring Boot):
@Target({ PARAMETER })
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Constraint(validatedBy = DomainKeyValidator.class)
...
0
votes
0
answers
348
views
AnnotationUtils.findAnnotation not gives path value when restMethod uses GetMapping
I was trying to setup usage of REST APIs in one of our application. SO I was trying to achieving this with interceptor approach.
The problem i was having as we are having two kinds of restful ...
0
votes
1
answer
1k
views
Spring Boot: @ModelAttribute is null in controller method when using with multipart/form-data
I have a Spring Boot controller method that handles file uploads, and I'm trying to use the @ModelAttribute annotation to bind some fields from the request. Here's my controller method:
@PostMapping(...
0
votes
1
answer
1k
views
Cannot find method 'value()' in the @Qualifier annotation
Over here I get an error saying qualifier cannot find method value in it where I can pass a name:
@Qualifier("abstractLanguageService")
public abstract class Ae implements Le {
// ...
}
...
-1
votes
1
answer
54
views
For GET web service , it is working fine in local and same code is not working in web logic server
For GET web service , while hitting the WebService in postman, able to retrieve data from local and same code is not working in web logic server.
Input data format : JSON
Output data format : JSON
For ...
0
votes
0
answers
88
views
Custom annotation for file validation not working: Spring 3.1.2
I recently updated my application to Spring 3.1.2 and I created a custom annotation which is not getting triggerred when applied on Method. Below is the code for the same.
The annotation.
@Documented
@...
0
votes
1
answer
672
views
Spring Boot Custom Validator Not Found Error: HV000030
Total newbie having trouble learning how to modify a spring boot application with a custom validator(maven, h2 repository, thymeleaf, not sure if this info is implied or necessary so here it is). I ...
0
votes
1
answer
447
views
CommandLineRunner in springboot is not executed
My CommandLineRunner class
package course;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
@Component
public class CourseCommandLineRunner ...
1
vote
2
answers
701
views
Hibernate: cascade create object from Map field (Map.key)
I have in Class a field Map<Object, String> type. How can I save Object's from Map when parent Class object save?
I understand whats the problem, but cant solve it. I cant place annotation @***...