Results 1 to 4 of 4

Thread: Main class.

  1. #1
    Join Date
    Jun 2010
    Posts
    2

    Default Main class.

    Hi, I used spring once about a year ago and I've completely forgotten how I setup my main class.

    I recall that with spring I was able to have a Main(){} that didn't have a static main method, and that this was somehow handled by spring. Is this possible? If so, how was it done.

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Seattle, Washington
    Posts
    467

    Default

    If you're writing a standalone Java class that you intend to run from the command line, you can't avoid the requirement of a "public static void main(String[] args)" method. This has nothing to do with Spring. Your "main" method will likely construct an instance of "ClassPathXmlApplicationContext".

    I suggest you read the Spring Reference Documentation and/or examine the numerous "Spring hello world" tutorials on the internet.

  3. #3
    Join Date
    Jun 2010
    Posts
    2

    Default

    So there's no situation where I can have a main without being static., ok that's fine I must be mistaken.
    and yes I have looked at the hello world tutorials, they all have static main, hence I'm here asking.

  4. #4
    Join Date
    Nov 2007
    Posts
    25

    Default

    In order to simplify main setup I have created https://jira.springsource.org/browse/SPR-9044. If you like the proposed approach, please vote for it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •