Questions tagged [jsr330]

JSR 330: Dependency Injection for Java

Specification: JSR 330

62 questions
1
vote
1 answer

Not able to use spring dependency injection across various classes for TestNG using java annotations(JSR 330 Standard Annotations)

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…
Raj Hassani
  • 1,577
  • 1
  • 19
  • 26
1
vote
3 answers

Error injecting a map using spring/JSR-330

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…
Andy N
  • 392
  • 3
  • 8
  • 24
0
votes
1 answer

When should I use binding annotations vs more-specific interfaces?

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…
user849827
0
votes
0 answers

How do you @Inject a list of @Named components using JSR-330?

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?
kane
  • 5,465
  • 6
  • 44
  • 72
0
votes
1 answer

Use annotation to feed Google guice MapBinder

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 =…
Thomas Decaux
  • 21,738
  • 2
  • 113
  • 124
0
votes
2 answers

Spring boot @ConfigurationProperties not working

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…
user2316771
  • 111
  • 1
  • 1
  • 11
0
votes
0 answers

How to use `javax.inject.Qualifier` to get bean in spring application context?

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…
Dean Xu
  • 4,438
  • 1
  • 17
  • 44
0
votes
0 answers

Spring MVC and CDI (Weld)

Is it possible to use Spring MVC and Weld in a Web Application? I'm also using WildFly 10.1 as my Server and RestEasy.
Fábio
  • 3,291
  • 5
  • 36
  • 49
0
votes
1 answer

Why is JSR-330 not working with Jersey and Spring

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 =…
qaxi
  • 472
  • 1
  • 4
  • 13
0
votes
1 answer

How can an application inform the Spring application context where to find a class whose constructor is annotated with @Inject?

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…
Derek Mahar
  • 27,608
  • 43
  • 124
  • 174
0
votes
1 answer

PicoContainer JSR-330 @Named support?

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…
Garret Wilson
  • 18,219
  • 30
  • 144
  • 272
0
votes
1 answer

Creating non-bean instances with Spring

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…
robert_difalco
  • 4,821
  • 4
  • 36
  • 58
0
votes
0 answers

How to use jsr 330 annotation in an "IoC container" independent manner?

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…
0
votes
1 answer

How to remove NullPointerException from JSR 330 Spring application

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…
TomR
  • 2,696
  • 6
  • 34
  • 87
0
votes
1 answer

how to inject Test-Implementation during tests, Production-Implementation in the production mode - Spring, JSR-330

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{ …
dpolaczanski
  • 386
  • 1
  • 3
  • 18