springboot 打war 包需配置的文件

 

一. pom.xml 文件添加 

    <packaging>war</packaging>

   <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
    </dependency>
    <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>4.0.1</version>
            <scope>provided</scope>
    </dependency>

 

二.   Application 文件 需要修改

// 打成 war 包 需配置
public class DataImportServiceApplication extends SpringBootServletInitializer {
    private static Logger logger = LoggerFactory.getLogger(DataImportServiceApplication.class);

    public static void main(String[] args) {
        SpringApplication.run(DataImportServiceApplication.class, args);
        logger.info("SpringBoot Start Success");
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        // 注意这里一定要指向原先用main方法执行的Application启动类
        return builder.sources(DataImportServiceApplication.class);
    }
}

 

三, 在 Terminal 终端中输入 命令  

mvn clean install 

 

四,异常 

[ERROR] Failed to execute goal on project data_import_servicejava: Could not resolve dependencies for project com:data_import_servicejava:war:0.0.1-SNAPSHOT: Failure to find kingbase.jdbc:KingBaseJdbcDriver8:jar:8.2.0 i
n http://maven.aliyun.com/nexus/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of alimaven has elapsed or updates are forced -> [Help 1]

当出现 打包过程中 在本地仓库存在,但是 maven aliyun 中央仓库 找不到包的情况。

解决方法:  修改本地maven库中文件。--找到本地仓库的包位置 ,找到文件 _remote.repositories 打开 添加 阴影部分的代码

#NOTE: This is an Aether internal implementation file, its format can be changed without prior notice.
#Thu Jun 17 13:30:48 CST 2021
KingBaseJdbcDriver8-8.2.0.jar>central=
KingBaseJdbcDriver8-8.2.0.jar>alimaven=
#KingBaseJdbcDriver8-8.2.0.jar>public=
#KingBaseJdbcDriver8-8.2.0.pom>public=

问题分析,以上包从第三方仓库下载来的,因为中央仓库没有该jar包,可以访问中央仓库地址

 

posted @ 2021-10-13 11:16  健身编程Dog  阅读(505)  评论(0编辑  收藏  举报