SpringBoot 入门(一)SpringBoot的搭建与配置

引言

搭建一个J2EE的web项目,要经过一系列步骤,如配置maven,集成jar,配置xml代码,然后开发代码,打包, 部署,测试等,Spring意识到这些很繁琐,且机械化,有共通性,可以实现自动化,因此提出直接一站式、整体解决方案,简化快速地开发应用。

网址

https://spring.io/projects/spring-boot
https://spring.io/guides
本人学习教程也附录上 :http://www.chilangedu.com/course/1489582623.html#0
版本说明 springboot 1.5.9

1、Maven设置

参考
https://www.jianshu.com/p/d9b3843810ec
https://www.jianshu.com/p/6654e9fec93b

<profile>  
  <id>jdk-1.8</id>  
   <activation>  
     <activeByDefault>true</activeByDefault>  
     <jdk>1.8</jdk>  
   </activation>  
<properties>  
<maven.compiler.source>1.8</maven.compiler.source>  
<maven.compiler.target>1.8</maven.compiler.target>  
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>  
</properties>
</profile>

helloworld工程(IDEA工具开发)

1、pom文件
<?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>myproject</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <!-- Inherit defaults from Spring Boot -->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.9.RELEASE</version>
    </parent>

    <!-- Add typical dependencies for a web application -->
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>

    <!-- Package as an executable jar -->
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
  </project>
编写Application Controller 代码

打包

在pom文件中添加以下插件

  <!--  该插件可以将应用打包成一个可以执行的jar包-->
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
部署

java -jar xxx.jar

springboot 场景启动器 starter

1、pom中的父项目
<parent>
    <groupId>org.springframework.boot</groupId<
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值