Need advice about which tool to choose?Ask the StackShare community!

CDI

30
38
+ 1
0
Spring

4K
4.8K
+ 1
1.1K
Add tool

CDI vs Spring: What are the differences?

Key Differences between CDI and Spring

CDI (Contexts and Dependency Injection) and Spring are both frameworks used for dependency injection in Java applications. While they have similarities in terms of managing dependencies, there are several key differences between the two.

  1. Configuration and XML Usage: CDI relies on annotations for configuration, allowing for type-safe usage and reducing the need for XML files. In contrast, Spring heavily uses XML files for configuration, providing more flexibility but also increasing the complexity of the configuration process.

  2. Scope Management: CDI provides a wider range of bean scopes, including built-in support for conversation, application, and request scopes. Spring, on the other hand, mainly focuses on Singleton and Prototype scopes, with other scopes available through third-party libraries.

  3. Integration: Spring is a more comprehensive framework that offers various modules for different purposes like security, web development, and data access. CDI, on the other hand, is primarily focused on dependency injection and does not provide the same level of integration capabilities as Spring.

  4. Transaction Management: Spring provides declarative transaction management using annotations or XML configuration. CDI, on the other hand, does not include built-in transaction management and relies on integration with other frameworks like Java Transaction API (JTA).

  5. Aspect-Oriented Programming: Spring has extensive support for Aspect-Oriented Programming (AOP), allowing developers to separate cross-cutting concerns from the main business logic. CDI does not have native support for AOP, and developers need to rely on external libraries or frameworks for AOP functionalities.

  6. Enterprise Capabilities: Spring is well-known for its comprehensive enterprise features, including advanced security configurations, batch processing, and enterprise integration patterns. CDI, although it provides CDI extensions for certain enterprise capabilities, does not offer the same extensive set of enterprise features as Spring.

In summary, while both CDI and Spring are dependency injection frameworks, they differ in terms of configuration, scope management, integration capabilities, transaction management, aspect-oriented programming support, and enterprise features.

Advice on CDI and Spring
Needs advice
on
DjangoDjango
and
SpringSpring

I am a graduate student working as a software engineer in a company. For my personal development, I want to learn web development. I have some experience in Springboot while I was in university. So I want to continue with spring-boot, but I heard about Django. I'm reaching out to the experts here to help me choose a future proof framework. Django or Spring Boot?

Thanks in Advance

See more
Replies (5)
Recommends
on
SpringSpring

Kamrul Hasan, Don't choose dying technologies with small communities. How many startups do you think use Spring and Django? Use Google Trends to compare technologies. Study the StackOverflow developer survey and job websites to see what technologies are wanted. Few teams can afford to train you to get up to their level so be a life-long learner. Embrace the dawn of a new industry and become an expert.

See more
Sulaiman Sanusi
Recommends
on
SpringSpring

I recommend you stick to Java Spring as you already have experience with the technology, i suggest you master this technology and then if Django seam to be very interesting to you, django is a framework you can easily pickup as python is also easy, you have to probably be able to manage the context switching between a static typed language like Java to dynamic language like python

See more
Gonzalo Fernández
Recommends

Hi Kamrul,

It really depends on the kind of project and whether you feel more comfortable with Java or Python. Both are excellent frameworks, with a huge community and learning material. I've been working with Spring Boot since I started coding almost and I can assure you it's the perfect combination for Java. The learning curve may be harder that Django, but once you know the basics you're good to go. I can't tell you much about Django but you must now by now that it has a great reputation with Python users. In any case I don't think you can go wrong with any of these two. My advice is, if you are already familiar with the Spring framework, give Spring Boot a try, because you're going to find out that it just makes the whole Spring experience so much easier. Let us know what you chose!

See more
Christoph Becker
Recommends
on
DjangoDjangoSpringSpring

It depends on what you want. Spring is Java-based whereas Django is Python-based. The question rather is Java vs Python. I personally recommend Python as it's shorter and easy to learn. But Java has advantages in really big systems.

See more
Recommends
on
DjangoDjango

Both are in active development and had huge community support. It really depends on you what you are comfortable with. Both are married to their respective languages. I choose Python over Java because of its simplicity and readability. To develop in java you need to write a lot of code. That's how java is. The best part I love with Django is its synchronization with Databases.

See more
Manage your open source components, licenses, and vulnerabilities
Learn More
Pros of CDI
Pros of Spring
    Be the first to leave a pro
    • 230
      Java
    • 157
      Open source
    • 136
      Great community
    • 123
      Very powerful
    • 114
      Enterprise
    • 64
      Lot of great subprojects
    • 60
      Easy setup
    • 44
      Convention , configuration, done
    • 40
      Standard
    • 31
      Love the logic
    • 13
      Good documentation
    • 11
      Dependency injection
    • 11
      Stability
    • 9
      MVC
    • 6
      Easy
    • 3
      Makes the hard stuff fun & the easy stuff automatic
    • 3
      Strong typing
    • 2
      Code maintenance
    • 2
      Best practices
    • 2
      Maven
    • 2
      Great Desgin
    • 2
      Easy Integration with Spring Security
    • 2
      Integrations with most other Java frameworks
    • 1
      Java has more support and more libraries
    • 1
      Supports vast databases
    • 1
      Large ecosystem with seamless integration
    • 1
      OracleDb integration
    • 1
      Live project

    Sign up to add or upvote prosMake informed product decisions

    Cons of CDI
    Cons of Spring
      Be the first to leave a con
      • 15
        Draws you into its own ecosystem and bloat
      • 3
        Verbose configuration
      • 3
        Poor documentation
      • 3
        Java
      • 2
        Java is more verbose language in compare to python

      Sign up to add or upvote consMake informed product decisions

      - No public GitHub repository available -

      What is CDI?

      It is a standard dependency injection framework included in Java EE 6 and higher. It allows us to manage the lifecycle of stateful components via domain-specific lifecycle contexts and inject components (services) into client objects in a type-safe way.

      What is Spring?

      A key element of Spring is infrastructural support at the application level: Spring focuses on the "plumbing" of enterprise applications so that teams can focus on application-level business logic, without unnecessary ties to specific deployment environments.

      Need advice about which tool to choose?Ask the StackShare community!

      What companies use CDI?
      What companies use Spring?
      Manage your open source components, licenses, and vulnerabilities
      Learn More

      Sign up to get full access to all the companiesMake informed product decisions

      What tools integrate with CDI?
      What tools integrate with Spring?

      Sign up to get full access to all the tool integrationsMake informed product decisions

      Blog Posts

      What are some alternatives to CDI and Spring?
      Marvel
      A super simple tool that turns any image (including PSDs) or sketch into interactive prototypes for any device. Powered by Dropbox.
      JavaScript
      JavaScript is most known as the scripting language for Web pages, but used in many non-browser environments as well such as node.js or Apache CouchDB. It is a prototype-based, multi-paradigm scripting language that is dynamic,and supports object-oriented, imperative, and functional programming styles.
      Python
      Python is a general purpose programming language created by Guido Van Rossum. Python is most praised for its elegant syntax and readable code, if you are just beginning your programming career python suits you best.
      Node.js
      Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.
      HTML5
      HTML5 is a core technology markup language of the Internet used for structuring and presenting content for the World Wide Web. As of October 2014 this is the final and complete fifth revision of the HTML standard of the World Wide Web Consortium (W3C). The previous version, HTML 4, was standardised in 1997.
      See all alternatives