1. 程式人生 > >Eclipse對spring-boot,spring-boot-mybatis的搭建

Eclipse對spring-boot,spring-boot-mybatis的搭建

安裝 OS arch true password username 數據 nbsp maven

1.準備工作

1.1.如果沒有sts(spring tool suite)插件, 則需要下載。

1.1.1.eclipse下載的話,一定要註意版本,因為eclipse會直接下載最新版本,如果ts版本與eclipse的對應不上,則會新建不了springboot工程。help--> Eclipse Marketplace,然後選擇Popular,選擇sts,點擊install。(註意:下載之前,maven的鏡像文件調整為aliyun的)。

下載完畢之後,如果版本不對,則需要更新:Help-->Install New Software-->work with 中輸入:http://dist.springsource.com/release/TOOLS/update/e4.6/

註意:e4.6是我的eclipse的版本,查看eclipse版本:help-->About eclipse,然後點擊eclipse圖標(一般來說都是第一個),找到Featrue name下的Eclipses Platform 查看版本。

1.2.也可以在這裏選擇下載:https://spring.io/tools/sts/legacy,安裝自行度娘。

2.新建sprint boot

2.1.new-->other-->spring boot,選擇spring stater project,根據需要填寫,在next之後,選擇web,選擇sql

,然後選擇數據庫,我的是mysql,我要整合mybatis,所以也點了mybastis。(如若只點擊web,就會成功的新建了spring boot)

2.2.新建完成後,會自行下jar包,如果maven版本太低,則pom會報一個org.codehaus.plexus.archiver.jar.Manifest.write(java.io.PrintWriter)錯誤。解決方案是:

  在help --> Install New Software > Work with中輸入如下,

https://otto.takari.io/content/sites/m2e.extras/m2eclipse-mavenarchiver/0.17.2/N/LATEST/,
然後回車,等待,安裝完畢後重啟即可。

配置數據庫連接:

spring.datasource.url=jdbc:mysql://localhost:3306/數據庫名字
spring.datasource.username=pass
spring.datasource.password=密碼
spring.datasource.driver-class-name=com.mysql.jdbc.Driver

#配置maper映射文件,在resource下的mapper文件下
mybatis.mapper-locations= classpath:mapper/*.xml



Eclipse對spring-boot,spring-boot-mybatis的搭建