部署弹簧引导应用程序是否需要 web.xml
2022-09-03 00:37:10
我试图将弹簧靴应用程序打包为战争。根据这个,我修改了我的应用程序类:
@SpringBootApplication
@EntityScan({"org.mdacc.rists.cghub.model"})
@EnableJpaRepositories(basePackages = {"org.mdacc.rists.cghub.ws.repository"})
public class Application extends SpringBootServletInitializer
{
public static void main( String[] args )
{
SpringApplication.run(Application.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
}
还在我的pom中添加了以下内容.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
当我打包项目时,我得到了以下错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-war) on project cg-web: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) -> [Help 1]
当我阅读弹簧启动应用程序时,我从未见过有关创建web.xml。在部署 spring boot 应用程序时是否需要 web.xml作为战争?