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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:36:49+00:00 2026-06-02T20:36:49+00:00

Edit : Here is some explanation of why the accepted answer works for me,

  • 0

Edit: Here is some explanation of why the accepted answer works for me, and possibly what could be a problem for others.

In my foo-app-servlet.xml, i have this line:

<context:component-scan base-package="com.foo.app" />

When I used spring2 before, all my service beans came from applicationContext.xml, but now they are being brought in directly in the foo-app-servlet.xml. On my project servlets have their own set of overrides, so I need to override in the servlet override file instead of the applicationContext override file.

When overriding, if you haven’t named your component then it does indeed use the lowercase version of it, so to override OrderService.foo, you do this:

orderService.foo=bar

End Edit

I’m working an a project that was upgraded from spring 2.5 to spring 3 and thus has both xml and annotation based config. We previously have used PropertyOverrideConfigurer to change properties in different environments to great success. I’m now working on code that uses authorize.net and I need to make sure I don’t send anything to them from the development environment.

In order to accomplish this I want to override my ‘testMode’ property with PropertyOverrideConfigurer. This works great for beans that are configured via xml, but I can’t figure out how to do it with annotation configured classes.

This is my override snippet from applicationContext.xml:

<bean class="org.springframework.beans.factory.config.PropertyOverrideConfigurer">
    <property name="location" value="file:${user.home}/override.properties" />
    <property name="localOverride" value="true" />
    <property name="ignoreResourceNotFound" value="true" />
</bean>

Here is the class with the property I want to override:

@Component
public class OrderService {
    private static Log logger = LogFactory.getLog(OrderService.class);

    @Autowired @Qualifier("OrderDAO") private OrderDAO orderDao;

    @Autowired private SiteManager siteManager;
    String authorizenetProperties = "classpath:authorizenet.properties";

    private Boolean testMode = false;

    public Boolean getTestMode() {
        return testMode;
    }

    public void setTestMode(Boolean testMode) {
        this.testMode = testMode;
    }

}

I’ve tried a few things that didn’t work:

com.foo.services.OrderService.testMode=true
OrderService.testMode=true

Is it possible to do what I want to do here? Does spring 3 have a new preferred way of doing this?

  • 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-02T20:36:52+00:00Added an answer on June 2, 2026 at 8:36 pm

    The PropertyOverrideConfigurer uses the key in your properties file as the bean name.bean property. When @Component autoscans your configuration, Spring will name the bean as the unqualified class name starting with a lower case. In your case, the OrderService bean should be named orderService. So, the following should work.

    orderService.testMode=true
    

    You can also name the bean by passing a name to the Component annotation like @Component("OrderService") or @Component("com.foo.services.OrderService"). None of this is new in Spring 3.x.

    Hope this helps

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

Sidebar

Related Questions

Edit: You can get the full source here: http://pastebin.com/m26693 Edit again: I added some
Im trying to hammer togehter a WYSIWYG-edit in c# following some examples from here
Could someone please provide explanation how Java multi-threaded program (e.g. Tomcat servlet container) is
When inserting values into my table what do I edit here? Do I delete
When a user links to link it redirects to edit.php - here's an example:
I'm looking to analyze and compare the following `signals': (Edit: better renderings here: oscillations
EDIT - The code looks strange here, so I suggest viewing the files directly
EDIT: See this in action here: http://jsbin.com/emobi/5 -- and that's using mouseenter/mouseleave. I have
Edit: OK I asked the wrong question here. I'm going to be coding a
EDIT Sorry I forgot the most important part here. Each key can have more

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.