DOES SPRING IOC CONTAINER WORK IN A JAKARTA EE 10 CONTAINER ?

150 views
Skip to first unread message

Chace n'b

unread,
Jul 24, 2023, 10:44:30 AM7/24/23
to WildFly
I have a web project (Spring 6.x, Jakarta EE 10, wildfly 28.x) in which I have been able to Implement dependency Injection using Jakarta CDI.
I've tried so bad to do the same using the spring IOC container with a java-based configuration but it seems like the spring IOC container is unabled to scan properly and detect beans when running on a Jakarta EE 10 container.

Question: Does Spring IOC container work when runnig in a Jakarta EE 10 container? 
If so, I'd like to have a glance at what I've been doing wrong. 

Thanks.

James Perkins

unread,
Jul 28, 2023, 11:15:14 AM7/28/23
to WildFly
This seems more like a Spring question and I'm far from a Spring expert, but I don't think Spring works with CDI. They have their own injection framework.

Chace n'b

unread,
Jul 28, 2023, 8:23:42 PM7/28/23
to James Perkins, WildFly
Thanks for the response. 
This question was because I heard about some integration that allows to use spring's annotations inside CDI beans.

I've been trying to replicate the spring's @Value annotation behaviour within a CDI environment using custom annotations, producer methods and custom qualifiers but I haven't been able to reproduce it. 

I ended up doing as follows :
- Creating a custom CDI bean (via producer method) of type Properties decorated with a custom Qualifier ;
- Inject that custom qualified Properties Bean inside any CDI bean ;
- Populate Class member values inside the PostConstruct method.

It looks messy I know. Any ideas on how to make this cleaner?

Thanks in advance

--
You received this message because you are subscribed to the Google Groups "WildFly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wildfly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wildfly/34afbab3-43c5-4733-87a9-f4b1acda141fn%40googlegroups.com.


--
                               
TCHASSEM N. Boris [cha...@gmail.com]
Ingénieur de conception en informatique: génie logiciel
Concepteur graphique chez CHACE COM [facebook.com/ChaceDesign]

James Perkins

unread,
Aug 2, 2023, 5:36:15 PM8/2/23
to WildFly
I'm sorry, I don't know enough about Spring to comment beyond what I have already.

Chace Boris

unread,
Aug 5, 2023, 5:31:16 AM8/5/23
to James Perkins, WildFly
That's fine. I appreciate your availability though.

Thanks 

Hantsy Bai

unread,
Aug 5, 2023, 10:23:06 PM8/5/23
to WildFly
it is not a big problem when using Spring 6 in a Jakarta EE 10 container,  check my example,

run `mvn clean wildfly:run -Pwildfly` to run the application, and tests `mvn clean verify -Pit-wildfly`.

Chace Boris

unread,
Aug 7, 2023, 2:28:14 PM8/7/23
to Hantsy Bai, WildFly
Thanks for the response Bai 先生

I can see that the @Value annotation is used inside a Spring bean as it should be.
I use CDI beans in my project instead of Spring Beans. 

I read some about jakarta's @Resource / @PropertySource that could act as spring's @Value.

I think I have my answer, Thanks for the answer.

Reply all
Reply to author
Forward
0 new messages