I have a service which I am trying to inject across various classes in my tests but I am getting its instance as null.
My config interface:
MyService.java
public interface MyService {
public String getHostUri();
}
My implementation class of…
I have 2 maven projects, a web-app, and a 'service' project. I am using spring to wire everything together. I would like to create a map in my application-context.xml, and have that injected into my class. When I try to start my web application I…
Question
What criteria should be used when deciding between:
specifying a dependency with an annotation, and
specifying a dependency with a more specific interface
Example
Suppose I have:
interface FooLoader {
Foo loadById(long id);
}
class…
Spring allows you to @Autowire a list of @Bean components.
A great example is already provided by Baeldung so I won't copy-paste it here.
Can I do the same thing with JSR-330 annotations?
In a Java project, build with Gradle 5.2, using Google Guice.
I use the MapBinder (http://google.github.io/guice/api-docs/latest/javadoc/com/google/inject/multibindings/MapBinder.html):
MapBinder mapbinder
=…
I'm using @ConfigurationProperties for auto configuration of properties. My code is working in IDE. But when I run the jar in command line, it is not working.
Configuration class:
@Configuration
@ConfigurationProperties(prefix="location")
public…
JSR-330 provide @Qualifier to qualifies beans. For example, define the following qualifier annotation.
@Qualifier
@interface Category{
String value();
}
and use it like this
@Bean
@Category("simple")
SomeThing get(){
return…
I have a bean with @RequestScope in it, and when I inject it in one of my Singletons, it is injected as a singleton and not as a request scope. However, if I change the @RequestScope to @Scope( value = "request", scopeName = "request", proxyMode =…
How can I fix the following example in order to inform the Spring application context where to find a class Application whose constructor is annotated with @Inject, but without introducing a bean method to ApplicationConfiguration annotated with…
PicoContainer seems to indicate that it supports JSR-330 @Inject and @Named. (No, this other question doesn't seem to help, as it doesn't address the fact that the PicoContainer site says that some support for JSR-330 has been added.)
I add…
I'm sure this has been asked a hundred times before but I can't seem to find the question so feel free to refer me to other stackoverflow answers.
What do most Spring users do for objects that are non-singleton beans that require injection? For…
Pardon my language if question is not clear. I want to use JSR 330 annotations. And I want to be able switch my DI provider. At present my application has to to know at some point that it has to use spring or google-guice. Is there any way I can…
I am implementing Spring+JSF application following the guidlines of http://www.mkyong.com/jsf2/jsf-2-0-spring-integration-example/ but I am using the latest Spring version (i.e. 3.x, it already contains the JSR 330 implementation, according to the…
Lets assume that I have sequencer and the following Beans. Sequencer is responsible for taking the next value from a database sequence.
OracleSequencer is used in the production mode, TestSequencer during JUnit-Tests.
public interface Sequencer{
…