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 8097573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:48:21+00:00 2026-06-05T21:48:21+00:00

Lets say I have a custom Annotation like below: public @interface myLimits { int

  • 0

Lets say I have a custom Annotation like below:

public @interface myLimits {

    int MIN_LIMIT = 400;

    int stockLimit() default MIN_LIMIT;
}

Instead of hard-coding the value of MIN_LIMIT in the annotation definition, can we externalize it to a properties file?

Something like below – Assuming “min.limit” is defined in a properties file.

public @interface myLimits {

    @value("${min.limit}")
    int MIN_LIMIT;

    int stockLimit() default MIN_LIMIT;
}

How do I externalize MIN_LIMIT instead of hard-coding?

  • 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-06-05T21:48:23+00:00Added an answer on June 5, 2026 at 9:48 pm

    Strictly speaking: you can’t. Annotations are processed in a separate compile round before the rest of the code, which means that everything that appears anywhere in an annotation must be a compile-time constant.

    Here’s what the JLS has to say about it:

    An element type T is commensurate with an element value V if and only
    if one of the following conditions is true:

    • T is an array type E[] and either:
      • V is an
        ElementValueArrayInitializer and each ElementValueInitializer
        (analogous to a variable initializer in an array initializer) in V is
        commensurate with E.
      • Or V is an ElementValue that is commensurate with
        T.
    • The type of V is assignment compatible (§5.2) with T and,
      furthermore:

      • If T is a primitive type or String, V is a constant
        expression (§15.28).
      • V is not null.
      • if T is Class, or an invocation of Class, and V is a class literal (§15.8.2).
      • If T is an enum type, and V
        is an enum constant.

    It is a compile-time error if the element type is
    not commensurate with the ElementValue.

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

Sidebar

Related Questions

Lets say I have a custom data type that looks something like this: public
Lets say have this immutable record type: public class Record { public Record(int x,
Lets say that we have a query like this one: SELECT *, (CUSTOM_EXPRESSION) as
Lets say I have hierarchy like this (This is just a test program. Please
Lets say I have model inheritance set up in the way defined below. class
lets say i have a custom widget which has a ClickHandler. Here's the example:
For example, lets say I have a page and 2 custom controls on that
Lets say we have <head> .. .. <meta property=og:description content=Default Description/> .. </hea> And
So, lets say I have a ComboBox with a custom data template. One of
Lets say I have a custom collection and a custom object that have a

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.