懺悔雲--SpringBoot環境搭建


SpringBoot環境搭建

環境安裝

  • 安裝eclipse,這個各位都會裝吧
  • 打開Help->Eclipse Marketplace
  • 在查詢框中輸入STS,安裝(什麼是STS呢?STS全稱爲Spring Tools Suite,是一個專門定製的爲Spring開發的插件)
  • 下載MAVEN,並解壓,配置好MAVEN(這個就自行百度吧)。 至此,Eclipse環境就算配置好了。

新建項目

  • 首先打開eclipse,新建一個Spring Starter Projects
  • 填寫好項目名,包名等資料後,點擊next
  • 選中web->web,意思是建立一個依賴WEB的項目
  • 點擊next->finish

集成jsp

添加依賴:java

<dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-jasper</artifactId> </dependency> <!-- servlet api --> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> </dependency> <!--jsp api--> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>javax.servlet.jsp-api</artifactId> <version>2.3.1</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> </dependency> 

配置jspmysql

spring.mvc.view.prefix=/ spring.mvc.view.suffix=.jsp 

集成Mybatis

添加依賴web

<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> </dependency> <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-devtools --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency> <!-- 自動更新--不須要從新部署 --> <dependency> <groupId>com.alibaba.spring.boot</groupId> <artifactId>dubbo-spring-boot-starter</artifactId> <version>1.0.0</version> </dependency> 
<!-- 配置掃描文件 --> <resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.xml</include> </includes> </resource> <resource> <directory>src/main/resources</directory> <includes> <include>**/*.*</include> </includes> </resource> <!--頁面--> <resource> <directory>src/main/webapp</directory> <targetPath>META-INF/resources</targetPath> <includes> <include>**/*.*</include> </includes> </resource> </resources> 

配置:spring

mybatis.mapper-locations=classpath:com/test/springboot/Mapper/*.xml spring.datasource.username=root spring.datasource.password= spring.datasource.driver-class-name=com.mysql.jdbc.Driver spring.datasource.url=jdbc:mysql://localhost:3306/technicalreview?useUnicode=true&characterEncoding=utf8&useSSL=false
相關文章
相關標籤/搜索