Skip to content

Instantly share code, notes, and snippets.

View colinbut's full-sized avatar
🎯
Focusing

Colin But colinbut

🎯
Focusing
View GitHub Profile
@colinbut
colinbut / Java8Snippet.java
Created August 18, 2015 20:19
Some Java 8 features - Lambdas, Streams, Method References
public class Java8Snippet {
public static void main(String[] args) {
List<String> names = Arrays.asList(new String[]{"Bobby", "Alice", "Emma", "Amy", "Anton"});
names.stream()
.sorted()
.filter(s -> s.startsWith("A")
.forEach(System.out::println());
}
}
DBConnection con = null;
Person person = new Person();
String sql = "select * from person p Where p.person_id = ?";
try {
con = getDBConnection();
con.prepareStatement(sql);
con.setInt(1, person_id);
con.executeQuery();
@Repository
public interface PersonRepository extends JpaRepository<PersonEntity, Integer> {
}
@colinbut
colinbut / multi-module-parent-pom.xml
Created March 18, 2018 22:55
Multi Module Parent Pom file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.multi.module</groupId>
<version>1.0</version>
<artifactId>multi-module-project</artifactId>
<packaging>pom</packaging>
<name>multi module project</name>
<modules>
@colinbut
colinbut / multi-module-child-pom.xml
Created March 18, 2018 22:57
Multi Module Child Pom file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- specifying the parent pom.xml file project -->
<parent>
<groupId>com.mycompany.multi.module</groupId>
<artifactId>multi-module-project</artifactId>
<version>1.0</version>
</parent>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.groupId</groupId>
<artifactId>artifactId</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>project-name</name>
<url>http://maven.apache.org</url>
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.0.RELEASE")
classpath('se.transmode.gradle:gradle-docker:1.2')
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!--
======================================================================
Mar 17, 2012 9:15:44 PM
project
description
Administrator
======================================================================
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
import static org.junit.Assert.*;
public class CalculationTest {
private Calculation classUnderTest = new Calculation();
private int number1;
private int number2;
@Before