SpringBoot实现学生在线交作业(一)——搭建SpringBoot环境

1.首先创建一个SpringBoot的项目,使用的工具是eclipse,创建一个spring starter project

 

 

2.在maven中导入jar包

<?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>   <!-- modelVersion 描述这个POM文件是遵从哪个版本的项目描述符 -->
     <parent>
           <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-starter-parent</artifactId>
           <version>2.1.4.RELEASE</version>
           <relativePath/>
     </parent>
     <groupId>com.example</groupId>
     <artifactId>SpringBoot</artifactId>
     <version>0.0.1-SNAPSHOT</version>
     <name>SpringBoot</name>
     <description>Demo project for Spring Boot</description>
     <properties>
           <java.version>1.8</java.version>
     </properties>
     <dependencies>
           <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter</artifactId>
           </dependency>
           <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-test</artifactId>
                <scope>test</scope>
           </dependency>
           
           <dependency>
                <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-starter-web</artifactId>
           </dependency>
           <!-- 热部署 -->
           <dependency>
                <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-devtools</artifactId>
           <optional>true</optional>
           </dependency>
           
            <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
           
            <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.7</version>
        </dependency>
           
            <dependency>
            <groupId>net.sf.json-lib</groupId>
            <artifactId>json-lib</artifactId>
            <version>2.4</version>
            <classifier>jdk15</classifier>
        </dependency>
        
           
           <!--  https://mvnrepository.com/artifact/org.mybatis.spring.boot/mybatis-spring-boot-starter -->
           <dependency>
           <groupId>org.mybatis.spring.boot</groupId>
           <artifactId>mybatis-spring-boot-starter</artifactId>
           <version>1.3.1</version>
           </dependency>
           
           <dependency>
                                <groupId>mysql</groupId>
                                <artifactId>mysql-connector-java</artifactId>
                                <scope>runtime</scope>
                           </dependency>
                           
                           <dependency>
                                <groupId>com.alibaba</groupId>
                                <artifactId>druid</artifactId>
                                <version>1.1.6</version>
                           </dependency>
     </dependencies>
     <build>
           <plugins>
                <plugin>
                     <groupId>org.springframework.boot</groupId>
                     <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>
           </plugins>
     </build>
</project>
 
-------------------------------------------------------
因为添加了mybatis-spring-boot-starter
而我们现在还没有配置数据库的内容,所以直接运行会报错,找到启动的main,把@SpringBootApplication改为
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })

3.运行测试

 

posted @ 2019-09-26 18:25  时光易久  阅读(566)  评论(0编辑  收藏  举报