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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:47:39+00:00 2026-06-14T10:47:39+00:00

read this article on SO , and had some clarifying questions. I put my

  • 0

read this article on SO, and had some clarifying questions.

I put my config.properties under src/main/resources

In spring-servlet.xml config file

I added the following:

<context:property-placeholder location="classpath:config.properties"/>

In my business layer, I am trying to access it via

@Value("${upload.file.path}")
private String uploadFilePath;

Eclipse shows error:

The attribute value is undefined for the annotation type Value

Can i not access the property in the business layer or are property files only read in the controller?

UPDATE::
src/main/java/com.companyname.controllers/homecontroller.java

public String home(Locale locale, Model model) {
    MyServiceObject myObj = new MyServiceObject();
    System.out.println("Property from my service object: = " + myObj.PropertyValue());

    if(myObj.PerformService())
    {
      ///
    }
}

src/main/java/com.companyname.services/MyService.java

public class MyServiceObject {

    @Value("${db.server.ip}")
    private String _dbServerIP;


    public String PropertyValue() {

        return _dbServerIPaseURL;
    }



}

Another site where I found the explanation

  • 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-14T10:47:42+00:00Added an answer on June 14, 2026 at 10:47 am

    Please check that you import Value from org.springframework.beans.factory.annotation package:

    import org.springframework.beans.factory.annotation.Value;
    

    also the property placeholder must be declared in the respective context configuration file, in case of controller it’s likely Spring dispatcher servlet configuration file.

    update You are confusing property-placeholder that post processes bean values, that contain dollar symbol ${<property name>} with Spring expression language container extension that process values containing a hash symbol #{<Spring expression language expression>}, in the link you have shown the latter approach is used.

    regarding the instantiation of MyServiceObject myObj
    If you want the object to be managed by Spring you should delegate its creation to the container:

    • if MyServiceObject is a stateless service then it’s a singleton with the singleton bean scope, you should register it in your application context, for example with the following xml configuration:

      <bean class="my.package.MyServiceObject"/>
      

      and inject it to your controller:

      private MyServiceObject myServiceObject;
      @Autowired 
      public void setMyServiceObject(MyServiceObject myServiceObject){
         this.myServiceObject = myServiceObject;
      }
      
    • if many instances of MyServiceObject are required, you can declare it as a bean with some other (non-singleton) bean scope (prototype, or request, for example).
      However, as there’s only one instance of the controller, you can’t merely let the Spring container to autowire MyServiceObject instance to the controller field, because there will be only one field and many instances of MyServiceObject class. You can read about the different approaches(for the different bean scopes) for resolving this issue in the respective section of the documentation.

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

Sidebar

Related Questions

I have recently read the safe bool idiom article. I had seen this technique
I read this article : http://lwuit.blogspot.in/2008/06/lightweight-text-input-in-lwuit.html This article talks of autocomplete textfield embedded on
I read this article on how to use keytool to generate CSRs for your
I read this article where Ayende states NHibernate can (compared to EF 4): Collection
after read this article i tried generate EF model by System.Diagnostics.Process: Process myProcess =
I read this article Managing Hierarchical Data in MySQL At the end of this
I've read this article, Using reCAPTCHA with Google App Engine , it wasn't very
I have read this article from High Scalability about Stack Overflow and other large
I have read this article about 400% boost of your website . This is
I've read this article: Change the text of a UILabel (UIBarButtonItem) on a toolbar

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.