code_junkie

Autostart spring app

Nov 11th, 2011
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. public static void main(final String[] args) throws Exception {
  2. ApplicationContext ctx = new ClassPathXmlApplicationContext("context.xml", Boot.class);
  3. FooService fooService = (FooService) ctx.getBean("fooService");
  4. fooService.bar();
  5. }
  6.  
  7. <project>
  8. <modelVersion>4.0.0</modelVersion>
  9. <groupId>com.stackoverflow</groupId>
  10. <artifactId>stackoverflow-autostart-spring-app</artifactId>
  11. <version>0.1</version>
  12.  
  13. <dependencies>
  14. <dependency>
  15. <groupId>org.springframework</groupId>
  16. <artifactId>spring</artifactId>
  17. <version>2.5.2</version>
  18. </dependency>
  19. </dependencies>
  20. <build>
  21. <plugins>
  22. <plugin>
  23. <artifactId>maven-jar-plugin</artifactId>
  24. <configuration>
  25. <archive>
  26. <manifest>
  27. <mainClass>com.stackoverflow.spring.autostart.Autostart</mainClass>
  28. </manifest>
  29. </archive>
  30. </configuration>
  31. </plugin>
  32. <plugin>
  33. <groupId>org.apache.maven.plugins</groupId>
  34. <artifactId>maven-shade-plugin</artifactId>
  35. <executions>
  36. <execution>
  37. <phase>package</phase>
  38. <goals>
  39. <goal>shade</goal>
  40. </goals>
  41. </execution>
  42. </executions>
  43. </plugin>
  44. </plugins>
  45. </build>
  46. </project>
  47.  
  48. java -cp myapp.jar util.SpringMain context.xml
Add Comment
Please, Sign In to add comment