intellij+spring boot +tomcat 部署網站

資源配置:

主機:Ubuntu14.04

工具:intellij ,mysql,tomcat

File>new>project


選擇Spring Initalier

一路next,到

選擇web

選擇Template>Thymeleaf

選擇sql>mysql

這三個都是添加依賴的,如果這裏不勾選,可以後面到pom.xml進行添加,intellij會自動下載

然後finlish ,項目就創建好了。

首先設置一下tomcat,這個在以後做web項目的時候都會用到

RUN>Edit Configurations

點擊右上方的+,添加一個tomcat

選擇Local


會自動識別出來你的tomcat,然後apply>ok,就可以了

然後就是代碼層了

代碼結構如下,記得把css,js ,image等放在staic下,html裏面的link才能找的到,如果在staic下面直接放html,可以直接通過localhost/hello.html,去訪問。



放在templlates下的需要在contrlller層進行回傳。

代碼路徑:https://github.com/wangjing1215/spring_boot_web.git

代碼太多了,這裏就不粘了,直接下載就OK

Mysql數據庫的配置:

其中username,password和database都要改成自己的

代碼代碼,勤學多練


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章