SpringBoot学习(一)打包运行

运行项目

  • 简单的命令行启动项目
    项目所在目录
mvn spring-boot:run

单模块打jar包

//-Dmaven.test.skip=true 跳过单元测试,不执行测试用例,也不编译测试用例类
// -U 更新第三方包
mvn -Dmaven.test.skip=true -U clean package

多模块打jar包

  • eg 我的项目模块如下所示

1.在最外层的pom文件中设置主配置类

<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <!--  设定主配置类 -->
                <configuration>
                    <mainClass>com.example.SpringbootApplication</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>

2.将1中的内容,放置到主运行模块的pom中

3.在项目所在目录运行打包命令

mvn -Dmaven.test.skip=true -U clean package

4.结果如下

5.以下命令运行

多模块打包war包

  • 项目结构同上一致

1.在web模块修改打包模式为war

2.添加如下目录(若无)

3.运行命令

4.结果如下

5.运行war

再次运行

  • 回到项目根目录,安装本地目录
D:\coding\springboot\web>cd ..

D:\coding\springboot>mvn -Dmaven.test.skip=true -U clean install

注意:以上项目结构内容跟着操作在变动
菜鸟一枚
记录下来,以免忘记,如有不妥,敬请提示

猜你喜欢

转载自www.cnblogs.com/VVII/p/12392423.html
今日推荐