準(zhǔn)備重拾編程。
從java入手,準(zhǔn)備達(dá)到快速搭建web站、開發(fā)Android應(yīng)用的水平。
第一階段:看視頻教程。
因?yàn)楣ぷ鬏^忙,只能走馬觀花地看完了馬士兵的課程,也看了基礎(chǔ)的Android教程。該階段勉強(qiáng)算完成了。
第二階段:看書、看文檔,做簡(jiǎn)單項(xiàng)目。
準(zhǔn)備Spring boot著手,搭建個(gè)簡(jiǎn)單blog。
第三階段:開發(fā)Android APP。
書已經(jīng)買好了,《深入理解Android:WebKit卷》準(zhǔn)備對(duì)著敲一個(gè)瀏覽器出來(lái)。
ps,tip下最近搭建Spring boot 操作數(shù)據(jù)庫(kù)遇到的問(wèn)題
1、由于使用visual studio code開發(fā),不熟悉vs code 開發(fā)spring boot,以至于spring boot新建項(xiàng)目后,缺少各種依賴報(bào)錯(cuò)。
2、添加了依賴,還有配置不對(duì)的。真心煩!
錯(cuò)誤:DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
解決:application.properties增加一行配置
spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
3、提示數(shù)據(jù)庫(kù)連接錯(cuò)誤,時(shí)區(qū)不被識(shí)別
錯(cuò)誤:com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server time zone value '...亂碼' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
解決:application.properties的數(shù)據(jù)庫(kù)URL后設(shè)置下時(shí)區(qū)params,serverTimezone=UTC
spring.datasource.url=jdbc:mysql://localhost:3306/myblog?serverTimezone=UTC
4、spring boot select成功,insert無(wú)效??吹墓俜轿臋n,一步一步敲的代碼!看來(lái)我的理解能力還是差啊,要么是因?yàn)闆](méi)有spring 基礎(chǔ)直接看spring boot了??
package com.test.myblog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping(path="/")
public class MainController{
@Autowired
private UserRepository userRepository;
@GetMapping(path="/adduser")
public @ResponseBody String addNewUser(@RequestParam String name,@RequestParam String pwd,@RequestParam Integer permission){
//創(chuàng)建新的Entity類對(duì)象User
User newUser=new User();
newUser.setName(name);
newUser.setPwd(pwd);
newUser.setPermission(permission);
//繼承CrudRepository的接口保存該對(duì)象,官方文檔無(wú)該步驟,是我瞎了么?
userRepository.save(newUser);
return "Saved Success!";
}
@GetMapping(path="/alluser")
public @ResponseBody Iterable<User> getAllUser(){
return userRepository.findAll();
}
}
5、學(xué)習(xí)了簡(jiǎn)書如何添加代碼塊,風(fēng)中凌亂
,不過(guò)我喜歡。