本人微信公众号"aeolian"~

SpringBoot添加WEB模块

添加Web模块

打开Structure,在Modules中添加Web模块,并配置好web.xml喝web根路径

《SpringBoot添加WEB模块》

 

Package到jar中

上面的添加好后直接运行在浏览器中可以访问,package打包成jar包后发现访问不了,原因是没把webapp模块打包到jar中。

在pom文件的build节点下添加resource配置,目的是将webapps下的目录打包到jar文件的META-INF\resources目录下

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.bootgroupId>
                <artifactId>spring-boot-maven-pluginartifactId>
            plugin>
        plugins>
        <resources>
            <resource>
                <directory>src/main/webappdirectory>
                <targetPath>META-INF/resourcestargetPath>
                <includes>
                    <include>**/**include>
                includes>
            resource>
            <resource>
                <directory>src/main/resourcesdirectory>
                <includes>
                    <include>**/**include>
                includes>
                <filtering>falsefiltering>
            resource>
        resources>
    build>

《SpringBoot添加WEB模块》

点赞

Leave a Reply

Your email address will not be published. Required fields are marked *