美文网首页
Springboot

Springboot

作者: 華華公子 | 来源:发表于2018-12-07 00:09 被阅读0次

    spring-cli使用

    新建一个springboot工程,包名以及工程名

    spring init  --dependencies=web --artifactId=springdemo --groupId=org.yiva.example 
    

    springmvc依赖

    <dependency>
           <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <!--tomcat启动-->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
    </dependency>
    

    移除tomcat

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <!-- 移除嵌入式tomcat插件 -->
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-tomcat</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <!--打包的时候可以不用包进去,该依赖理论上可以参与编译,测试,运行等周期。
            相当于compile,但是打包阶段做了exclude操作-->
        <scope>provided</scope>
    </dependency>
    

    以War方式打包

    $ spring init --build=maven --java-version=1.8 --dependencies=web --packaging=war demo.zip
    

    以gradle方式构建

    $ spring init --build=gradle
    

    相关文章

      网友评论

          本文标题:Springboot

          本文链接:https://www.haomeiwen.com/subject/awczcqtx.html