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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:45:54+00:00 2026-05-22T22:45:54+00:00

I have the following simple constructor: public SimpleClass(Type1 arg1, int interval = 1000) {

  • 0

I have the following simple constructor:

public SimpleClass(Type1 arg1, int interval = 1000)
{ ... }

I’m initialising this using the spring framework as follows, without using autowire:

<object name="SimpleClass" type="..., ...">     
    <constructor-arg name="arg1" ref="..." />
    <constructor-arg name="interval" value="1000" />    
</object>

My question is: Since I’m defining a default value for the second parameter in the actual constructor, can I leave it out of the spring config file, or does spring need an explicit declaration for all parameters if you don’t use autowire? Is there any point in leaving in a default parameter value here, since I’m using spring?

  • 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-22T22:45:55+00:00Added an answer on May 22, 2026 at 10:45 pm

    That does not work when using xml configuration (tested it with Spring.NET 1.3.1).

    It probably does work when using CodeConfig, but I haven’t tried it out.

    Quickest work-around would be to simply introduce a second constructor in your class:

    Class SimpleClass
    {
      public SimpleClass(Type1 arg1) : this(arg1, 1000)
      {}
    
      public SimpleClass(Type1 arg1, int interval = 1000)
      { 
        // ...
      }
    }
    

    That will always work.

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

Sidebar

Related Questions

I have a very simple constructor in ActionScript as the following: public function ButtonTest()
I have the following simple function: private void EnableDisable941ScheduleBButton() { if (this._uosDepositorFrequency.Value != null)
I have the following simple Java code: package testj; import java.util.*; public class Query<T>
i have the following simple code, but it doesn,t work <ul> <li id=one onmouseover=this.style.background-color='white';>
Let's say I have the following structure declaration (simple struct with no constructor). struct
I have a simple console application where I have the following setup: public interface
I'm using Google Guice for dependency injection. Suppose I have the following: public interface
I've got a simple domain object, Movie , with the following constructor: public Movie(string
I have following simple class: @interface Article: NSObject { NSString *title; } @property (copy,
We have the following simple Stored Procedure that runs as an overnight SQL server

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.