Skip to main content

Questions tagged [autowired]

Autowiring is a DI container feature where the dependencies are automatically looked for according to some criteria.

-1 votes
0 answers
32 views

Is it possible to use Reflection along with @Autowired annotation to access to fields of a private class?

I am writing tests for a project and I want to access to private field of a class that otherwise should not be accessed. The reason behind this is that I don't want to fill the database with ...
enanas's user avatar
  • 35
1 vote
1 answer
33 views

Consider defining a bean of type service in your configuration

I have been learning Spring Boot for a week now yesterday I faced an error ` Field db in com.example.test.tutorial.TutorialApplication required a bean of type 'com.example.test.tutorial.DB' that could ...
Sudipa Sarkar's user avatar
-1 votes
0 answers
20 views

why string1 is null when getting it from ApplicationContext and manually setting it into String1 type of variable, in springBoot project

I'm trying to understand why this code is throwing Nullpointer exception. This is callback1 class, has String1 as setter dependency. I'm setting this manually by taking it from ApplicationContext and ...
Arti Prajapati's user avatar
0 votes
0 answers
43 views

Using @Autowired in abstract class with generics: 'No beans of Generic type found' warning in IntelliJ but autowiring still works

Edit: One detail I missed out. The warning that I'm seeing is reported by IntelliJ. I have also seen others mention using the Spring Data plugin but I already have that. Let's say I have ten ...
Kamehamehachoo's user avatar
0 votes
2 answers
59 views

Java spring bean is getting created and added to the context but not @Autowired

I have a JavaFX application with Spring. I have a bean in a Configuration class which is being correctly added to the SpringContext, and can be retrieved manually, but it is not getting autowired into ...
spl's user avatar
  • 590
0 votes
2 answers
48 views

Spring Boot @PrePersist Listener: "this.partido" is null

I'm a beginner in Spring and I'm trying to use a @PrePersist listener to validate a Partido entity before it is saved to the database. However, I keep encountering the error: java.lang....
Xavier Guerrero's user avatar
0 votes
0 answers
29 views

Spring refresh an autowired bean during runtime

I have a property that i need to change on the fly. As beans are created and autowired on startup, even if i change the bean during runtime is not taking into effect. Ex: Class serviceA { Instant ...
ging's user avatar
  • 253
-1 votes
1 answer
38 views

@Autowired component Null [duplicate]

I don't know why, but my @Autowired component (jwtService) returns a NullPointerException. Here is my code: This is my JwtTokenValidator class: @Component @AllArgsConstructor @NoArgsConstructor public ...
abdelouadoud laadimi's user avatar
2 votes
0 answers
46 views

How to autowire a Spring Boot bean depending on a request attribute?

I'm working on a Spring Boot application where I have two implementations of a particular service, a real one and a proxy one. The interface looks like this: @Service public interface RefundService { ...
Mauro Chojrin's user avatar
1 vote
1 answer
33 views

@Autowire on singleton bean in class field and method parameter gives different instances

Please take a look at code below: import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org....
Jasiu's user avatar
  • 23
-1 votes
1 answer
64 views

Why in Spring @Autowired annotation on a constructor is no longer necessary if the target bean only defines one constructor? [duplicate]

I am in the beginning of study of Spring framework and I read this in Spring official docs. "As of Spring Framework 4.3, an @Autowired annotation on such a constructor is no longer necessary if ...
Sara Alaa Ragab's user avatar
0 votes
1 answer
35 views

Spring JPA failing to find repository

Spring JPA application is failing to find the repository. I have tried annotating it with @repository, putting the controller, service and repository in component scan etc but I'm not having any luck. ...
Hywel Griffiths's user avatar
0 votes
0 answers
22 views

defined in @EnableJpaRepositories declared on LostandfoundApplication: Not a managed type: class com.lostandfound.lostandfound.model.Item

LostandfoundApplication.java package com.lostandfound.lostandfound; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org....
Vamshidhar Dawoor's user avatar
0 votes
0 answers
22 views

Ignore Self-Certificate with RestTemplate in a Simple and Standard Way

Is there a simple way to allow uncertifiable REST responses with RestTemplate without throwing an error? The solution is and won't be able to use any ISPs, Certificate Authorities (CAs), or many ...
Zach's user avatar
  • 735
0 votes
0 answers
30 views

How does autowiring by parameter name works in Spring?

I have the following working example where beans are autowired by parameter name. Note that it is working and no qualifiers used. How this can be done? I can't reproduce it in my project. @Component ...
Dims's user avatar
  • 49.9k

15 30 50 per page
1
2 3 4 5
188