Questions tagged [autowired]

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

In a like , the beans to be injected can be explicitely configured or they can be searched for automatically in what is called "autowiring".

Although the concept is not exclusive to Spring, the bulk of questions in Stack Overflow and Google seem to be directed towards this framework.

Spring

In the particular case of Spring, when "autowiring" is enabled, the container will look in the current ApplicationContext for a bean that matches the type/name of the corresponding setter method.

Autowiring can be configured globally or on each bean to be disabled; or enabled by type, by name, by constructor type. It can also be configured using the Autowired annotation.

2781 questions
0
votes
0 answers

How to read values from configuration classes in custom logback appender class in spring web application?

I want to customize logback append method so it can take some parameters from application.yaml file.(I am not going detail about the business.) Here is my configuration…
Harun Acar
  • 109
  • 1
  • 13
0
votes
0 answers

Spring Boot Service always null after @Autowire in JavaFX Controller Class

I am currently developing an application that uses Spring Boot and JavaFX. I want to store email and password in H2 database. With a JUnit test I have already checked if the database is running and I have access to the Spring Boot repository. This…
Maik
  • 11
  • 4
0
votes
1 answer

Symfony problem with autowire on server (Local works correcty)

I have problem with autowire on my server. Symfony show me this: Cannot autowire argument $authenticationUtils of "App\Controller\LoginController::index()": it references class "Symfony\Component\Security\Http\Authentication\AuthenticationUtils" but…
0
votes
0 answers

Can spring hibernate project be attached as jar in another maven project

I have a spring-hibernate-springboot project deploying as WAR. I need to use it as jar in another JAVA project. I have seperated its controller part and now made changes in maven to deploy it as jar. I am able to attached it to another project and…
charmi
  • 197
  • 3
  • 17
0
votes
1 answer

Use a custom mapper inside another custom mapper with mapstruct (in default method)

I want to use MapperB inside MapperA's default method Similar to this question: How can I use another mapping from different class in mapstruct However afaik this question did not ask for 'custom mappers', i.e. mappers that exist as their own…
Chef Lax
  • 89
  • 2
  • 10
0
votes
1 answer

Create a Spring Bean programmatically, but with Autowired within it

How do I instantiate a Spring Bean that has some @Autowired beans within it? The caveat is that the instance bean type must be discovered dynamically at runtime (whereas the @Autowired bean can still be singleton). Example: Interface public…
Michael C
  • 53
  • 6
0
votes
2 answers

how to use constructor autowried

I can get it working using field autowired. @Component public class ZMyServiceConstructor { @Autowired private RestTemplate restTemplate; @Value("${my_test_property}") private String url; } I'd like to use constructor autowried.…
Abe
  • 310
  • 3
  • 15
0
votes
0 answers

@Autowired not working on EC2 instance after Corretto Java 17 upgrade, but works fine on local instance

I recently used Corretto to upgrade our EC2 instance from Java 11 to Java 17. Since then, I am unable to start the existing application on EC2 instance, even though it runs fine locally See below: LOCAL $ java --version java 17.0.5 2022-10-18…
Bradley D
  • 2,333
  • 1
  • 15
  • 19
0
votes
3 answers

Repository that extends JpaRepository cannot be autowired into my Service

I have UserRepository Interface that extends Jpa REpository Interface when Im trying to autowire it into a Servise or a Controller I recieve such an error - Parameter 0 of constructor in com.example.boottestfinal.UserHelper required a bean of type…
0
votes
1 answer

How to declare parameters of a service of my bundle

I'm creating a bundle for a few Symfony projects. This bundle contains one service and this service is created with a constructor containing an array as first and unique parameter. Developers who will use my bundle have to declare this array in the…
Alexandre Tranchant
  • 4,426
  • 4
  • 43
  • 70
0
votes
1 answer

Cannot autowire service ServiceEntityRepository no such service exists. Symfony under API Platform

We are using API Platform to build our APP and we got stuck into a bug that looks environment related to us. We are 4 developpers, 3 of us under windows have the same issue while the one under mac os can't reproduice it and everything's working fine…
Cortodev
  • 11
  • 2
0
votes
0 answers

Field is null after contstructor - spring

@RestController @RequestMapping("/v1/users") public class UserController { private final UserService userService; public UserController(UserService userService) { System.err.println(userService); this.userService =…
Ayshan Rzayeva
  • 137
  • 2
  • 11
0
votes
1 answer

Generic type reverse lookup with Spring Boot @Service autowirings

Spring Boot & Java 11 here. I have an abstract base class: public abstract class AbstractBurninator { // ... } And some subclasses, such as: public class FizzBurninator extends AbstractBurninator {} public class BuzzBurninator extends…
hotmeatballsoup
  • 385
  • 6
  • 58
  • 136
0
votes
0 answers

MapStruct Mapper Bean not found

I am trying to create a mapper for my Capteur class : Capteur: package fr.projettresscientifique.reel.referentielreel.model.java; import lombok.Getter; import lombok.Setter; @Getter @Setter public class Capteur { private Integer id; …
Gochou
  • 1
  • 1
0
votes
1 answer

Spring Boot autowire not working. Required bean, of type that could not found

I'm getting the following error when using autowire in spring boot *************************** APPLICATION FAILED TO START *************************** Description: Field candidateRepository in…
1 2 3
99
100