Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7410177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:11:42+00:00 2026-05-29T06:11:42+00:00

In Java, is it a good practice to use annotations to configure an application

  • 0

In Java, is it a good practice to use annotations to configure an application rather than using XML files? I am more skeptical about it because, using annotations involves changing the java source files and it is as good as declaring constants in java files and then using those constants, whereas when we make the configurations using XML files, we can keep all the configuration changes away from java source files and keep the configurations in separate XML files, this approach sounds more neat. Also, when we need to make changes to configuration, we know which XML file to change rather than searching the java files for the annotations. Also, we can update an XML file in an EAR without compiling the code again, whereas if we make any change in an annotation, then we need to compile the code again.

Can anybody please throw some light on why should we use annotations and not XML files for configuration?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:11:44+00:00Added an answer on May 29, 2026 at 6:11 am

    Which to use may vary depending on what’s being configured, how the configuration is used, project/cultural conventions, etc. Good IDE support makes using either more convenient and reliable.

    Personally, while I use both XML and annotations, I tend to prefer XML configuration for many tasks, particularly on larger projects. For example, with Spring, I prefer XML configuration: it’s easier to manage the configuration itself, configuration changesets, and environment-specific changes (e.g., testing, server-based, etc.), when it’s more localized.

    For other configurations, annotations are often more appropriate and convenient. For quick projects with little or no domain class customization, Hibernate annotations may be more convenient.

    Ultimately it’s a matter of preference and convenience rather than a purely technical one. (Except when the XML and annotations support different features; sometimes one offers more-complete capabilities.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It is good practice to use the main method to test a java/.net class?
In Java classes is it considered good or bad practice to access member fields
For many reasons, it is not good practice to use threads inside a servlet.
It is a known fact, that in Java it is good practice to return
I know that in Java, it is common practice to use get as a
I am from Java Swing background. May I know why using XML to create
Never was good at these things. We are using Checkstyle (for Java) to enforce
I am creating a java API for an addressbook Is it a good practice
I want to use protobuff in a Java application to facilitate serialization and I
Search for good JAVA lib for playing with POST-GET requests - Is there any

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.