autowired

How can i combine Guice and Mapstruct?

若如初见. 提交于 2021-01-28 05:50:34
问题 I'm using jersey and Guice DI and I want to use Mapstruct interfaces with @Inject annotation. So is there some way to force Guice to autowire Mapstruct interface implementations ? 回答1: You can configure the implementations of the Mappers to be annotated with JSR 330 annotation by using @Mapper(componentModel = "jsr330") . You can find more information in the reference documentation. You can then bind the Mapper interface with the implementation class in your modules. One way to bind them is

Autowire symfony CacheInterface depending on environment

天涯浪子 提交于 2021-01-27 22:50:10
问题 I am trying to use different cache system on my environments. I would like to have, for example, Filesystem for dev and memcached for prod . I am using symfony 3.3.10 . To achieve this, I would like to autowire the CacheInterface as follow: use Psr\SimpleCache\CacheInterface; class Api { public function __construct(CacheInterface $cache) { $this->cache = $cache; } } Here are my configuration files: config_dev.yml : framework: cache: app: cache.adapter.filesystem config_prod.yml : framework:

Autowiring of Freemarker configuration fails

こ雲淡風輕ζ 提交于 2021-01-27 20:39:12
问题 I trying to use Freemarker Templating Engine to send html formatted emails. I had to do this in several services. In one service, freemarker is working fine, but not in another one. But the code, relevant for freemarker, is actually the same. The autowiring of @Autowired private Configuration freeMarkerConfig; is not working in one service, but in another. The autowiring appears in an hierachy (e.g. controller autowires service, service autowires a mailservice, mailservice autowires another

Spring dependency injection not working

自闭症网瘾萝莉.ら 提交于 2021-01-27 19:04:15
问题 I've got a problem in my standalone Java application. The thing is that I'm trying to Autowire both my Services and my DAOs, but I get a NullPointerException when I invoke service methods from the UI since dependency injection is not working properly. I've tried a lot of things, many of them from similar questions, but the problem is still there. I'm using Spring 4.0.6.RELEASE and Hibernate 4.3.11.Final. Here is my code: 1 - Invocation of service: public class LoginView { @Autowired private

Spring autowired collection of qualified beans

谁都会走 提交于 2021-01-06 10:45:57
问题 I have some Spring @Components with @Qualifier annotations, let's say it's in example "A" and "B". I want to inject them (using only annotations) into List. How can I do that ? @Component public class WhatIHave { @Autowired @Qualifier("A") private MyType firstBean; @Autowired @Qualifier("B") private MyType secondBean; .... } @Component public class WhatIWantToHave { @Autowired @Qualifier("A", "B") //something like that private List<MyType> beans; ... } Do I need to make it in @Configuration

pass different @Configuration bean to a rest based Client

耗尽温柔 提交于 2021-01-04 21:04:15
问题 I have two different configuration which i would be loading from application yml. The properties are same but the values might differ. How do i make this work giveMeRestTemplate(Type config) // app.yml bus: tyres:8 seats:40 color:red url: www.businfo.com car: tyres:4 seats:6 color:blue url: www.carinfo.com So i have different ConfigruationProperties class for this like below one other as CarConfig @ConfigurationProperties("bus") public class BusConfig{ public int tyres; public int seats;

pass different @Configuration bean to a rest based Client

僤鯓⒐⒋嵵緔 提交于 2021-01-04 20:42:50
问题 I have two different configuration which i would be loading from application yml. The properties are same but the values might differ. How do i make this work giveMeRestTemplate(Type config) // app.yml bus: tyres:8 seats:40 color:red url: www.businfo.com car: tyres:4 seats:6 color:blue url: www.carinfo.com So i have different ConfigruationProperties class for this like below one other as CarConfig @ConfigurationProperties("bus") public class BusConfig{ public int tyres; public int seats;

pass different @Configuration bean to a rest based Client

偶尔善良 提交于 2021-01-04 20:35:56
问题 I have two different configuration which i would be loading from application yml. The properties are same but the values might differ. How do i make this work giveMeRestTemplate(Type config) // app.yml bus: tyres:8 seats:40 color:red url: www.businfo.com car: tyres:4 seats:6 color:blue url: www.carinfo.com So i have different ConfigruationProperties class for this like below one other as CarConfig @ConfigurationProperties("bus") public class BusConfig{ public int tyres; public int seats;