Spring Boot for war

Spring Framework (24 Part Series)

1 Spring Configuration
2 External Properties in Spring
20 more parts…
3 Profiles in Spring
4 Spring Expression Language (SpEL)
5 How Spring implements Singleton Beans
6 Converting explicit into implicit configuration in Spring
7 Autowiring in Spring
8 Lazy Beans in Spring
9 @PostConstruct and @PreDestroy in Spring
10 Stereotype and Meta Annotations in Spring
11 Spring’s FactoryBean Interface
12 The Spring Bean Lifecycle
13 Spring AOP
14 Caching in Spring
15 Spring JDBC
16 Spring Transaction Management
17 JPA with Spring
18 JPA with Spring Boot
19 Spring Web MVC
20 Spring Boot for war
21 Spring MVC REST
22 Reactive Spring Applications
23 Spring Security
24 Spring Injection Types

Spring Boot supports the following embedded servlet containers:

  • Tomcat
  • Jetty
  • Undertow

You can use Maven, Gradle, or Ant/Ivy as build tools to generate the jar file. However, you may need to use your own server as WebLogic, Wildfly, JBoss, etc. In that case, you would need to generate a WAR file of your Spring Boot project. To do that you have to do the next changes:

  • Change artifact type to WAR
  • Extend SpringBootServletInitializer
  • Override the configure method
@SpringBootApplication
public class Application extends SpringBootServletInitializer {

    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }
}

Enter fullscreen mode Exit fullscreen mode

mvn package will create a hybrid and a traditional (.original) WAR. The traditional WAR is produced without the embedded tomcat. So, you can use the .war.original file in your application server.

Spring Framework (24 Part Series)

1 Spring Configuration
2 External Properties in Spring
20 more parts…
3 Profiles in Spring
4 Spring Expression Language (SpEL)
5 How Spring implements Singleton Beans
6 Converting explicit into implicit configuration in Spring
7 Autowiring in Spring
8 Lazy Beans in Spring
9 @PostConstruct and @PreDestroy in Spring
10 Stereotype and Meta Annotations in Spring
11 Spring’s FactoryBean Interface
12 The Spring Bean Lifecycle
13 Spring AOP
14 Caching in Spring
15 Spring JDBC
16 Spring Transaction Management
17 JPA with Spring
18 JPA with Spring Boot
19 Spring Web MVC
20 Spring Boot for war
21 Spring MVC REST
22 Reactive Spring Applications
23 Spring Security
24 Spring Injection Types

原文链接:Spring Boot for war

© 版权声明
THE END
喜欢就支持一下吧
点赞11 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容