Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(final String[] args) throws Exception {
- ApplicationContext ctx = new ClassPathXmlApplicationContext("context.xml", Boot.class);
- FooService fooService = (FooService) ctx.getBean("fooService");
- fooService.bar();
- }
- <project>
- <modelVersion>4.0.0</modelVersion>
- <groupId>com.stackoverflow</groupId>
- <artifactId>stackoverflow-autostart-spring-app</artifactId>
- <version>0.1</version>
- <dependencies>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring</artifactId>
- <version>2.5.2</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <archive>
- <manifest>
- <mainClass>com.stackoverflow.spring.autostart.Autostart</mainClass>
- </manifest>
- </archive>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </project>
- java -cp myapp.jar util.SpringMain context.xml
Add Comment
Please, Sign In to add comment