随笔分类 -  Java

摘要:public class Code { public static void main(String[] args) { Arrays.asList("red", "green", "blue") .stream() .sorted() .findFirst() .ifPresent(System. 阅读全文
posted @ 2020-12-30 03:43 Zhentiw 阅读(67) 评论(0) 推荐(0) 编辑
摘要:public class Code { public static void main(String[] args) { List<String> names = Arrays.asList("Paul", "Jane", "Sam", "Michaela"); // Way to sort pri 阅读全文
posted @ 2020-12-30 03:32 Zhentiw 阅读(85) 评论(0) 推荐(0) 编辑
摘要:Testing JWT proteceted endpoint: /** * HTTP POST /tours/{tourId}/ratings */ @Test public void createTourRating() throws Exception { restTemplate.excha 阅读全文
posted @ 2020-12-27 22:09 Zhentiw 阅读(209) 评论(0) 推荐(0) 编辑
摘要:Provider: package com.example.ec.security; import com.example.ec.domain.Role; import io.jsonwebtoken.*; import org.springframework.beans.factory.annot 阅读全文
posted @ 2020-12-27 22:01 Zhentiw 阅读(161) 评论(0) 推荐(0) 编辑
摘要:package com.example.ec.security; import com.example.ec.repo.RoleRepository; import org.springframework.beans.factory.annotation.Autowired; import org. 阅读全文
posted @ 2020-12-26 04:54 Zhentiw 阅读(86) 评论(0) 推荐(0) 编辑
摘要:Controller: @RestController @RequestMapping(path = "/ratings") public class RatingController { private static final Logger LOGGER = LoggerFactory.getL 阅读全文
posted @ 2020-12-26 04:33 Zhentiw 阅读(135) 评论(0) 推荐(0) 编辑
摘要:Service: package com.example.ec.service; import com.example.ec.domain.Tour; import com.example.ec.domain.TourRating; import com.example.ec.repo.TourRa 阅读全文
posted @ 2020-12-23 03:40 Zhentiw 阅读(469) 评论(0) 推荐(0) 编辑
摘要:If one request failed, we want to keep database untouched as if the request never happen. Spring makes it easy to add: @Transactional To the method or 阅读全文
posted @ 2020-12-23 02:14 Zhentiw 阅读(95) 评论(0) 推荐(0) 编辑
摘要:Repo: public interface CourseRepository extends CrudRepository<Course,Integer>{ Optional<Course> findByName(String name); @Query("Select new com.examp 阅读全文
posted @ 2020-12-20 20:40 Zhentiw 阅读(183) 评论(0) 推荐(0) 编辑
摘要:@Test public void queryByExample() { System.out.println("\nFind the Department with the name 'Humanities' \n" + departmentRepository.findOne(Example.o 阅读全文
posted @ 2020-12-18 04:24 Zhentiw 阅读(138) 评论(0) 推荐(0) 编辑
摘要:package com.example.university.repo; import com.example.university.domain.Staff; import org.springframework.data.domain.Page; import org.springframewo 阅读全文
posted @ 2020-12-18 04:20 Zhentiw 阅读(120) 评论(0) 推荐(0) 编辑
摘要:package com.example.university.repo; import com.example.university.domain.Staff; import com.example.university.domain.Student; import com.example.univ 阅读全文
posted @ 2020-12-18 04:10 Zhentiw 阅读(223) 评论(0) 推荐(0) 编辑
摘要:Entity: package com.example.university.domain; import javax.persistence.*; import java.util.ArrayList; import java.util.List; /** * JPA Entity represe 阅读全文
posted @ 2020-12-18 03:59 Zhentiw 阅读(109) 评论(0) 推荐(0) 编辑
摘要:All features of CrudRepository plus: void flush(); saveAndFlush() delteInBatch() delteAllInBatch() package com.example.university.repo; import com.exa 阅读全文
posted @ 2020-12-17 02:36 Zhentiw 阅读(112) 评论(0) 推荐(0) 编辑
摘要:domain/Course.java package com.example.university.domain; import javax.persistence.*; /** * JPA Entity for a Course offered at the University. * <p> * 阅读全文
posted @ 2020-12-17 02:31 Zhentiw 阅读(124) 评论(0) 推荐(0) 编辑
摘要:@OneToMany: One Student To Many Courses. @JoinTable(name = "Enrollment"): Join Enrollment table. joinColumns: with use "student_id" to link Student an 阅读全文
posted @ 2020-12-17 02:14 Zhentiw 阅读(308) 评论(0) 推荐(0) 编辑
摘要:Repo: package com.example.ec.repo; import com.example.ec.domain.TourRating; import com.example.ec.domain.TourRatingPk; import org.springframework.data 阅读全文
posted @ 2020-12-16 03:13 Zhentiw 阅读(95) 评论(0) 推荐(0) 编辑
摘要:package com.example.ec.web; import com.example.ec.domain.Tour; import com.example.ec.domain.TourRating; import com.example.ec.domain.TourRatingPk; imp 阅读全文
posted @ 2020-12-16 03:02 Zhentiw 阅读(291) 评论(0) 推荐(0) 编辑
摘要:Controller: package com.example.ec.web; import com.example.ec.domain.Tour; import com.example.ec.domain.TourRating; import com.example.ec.domain.TourR 阅读全文
posted @ 2020-12-15 02:53 Zhentiw 阅读(116) 评论(0) 推荐(0) 编辑
摘要:In software, we come across many use cases when we need to have a composite primary key to define an entry in a table. Composite primary keys are keys 阅读全文
posted @ 2020-12-15 02:05 Zhentiw 阅读(206) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示