Announcement Announcement Module
Collapse
No announcement yet.
Main class. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      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.

      Comment


      • #4
        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.

        Comment

        Working...
        X