-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4396deb
commit f3e47d4
Showing
19 changed files
with
676 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
src/main/java/com/wxnacy/spring/Application.java | ||
src/main/java/com/wxnacy/spring/UserController.java | ||
src/main/java/com/wxnacy/spring/UserRepository.java | ||
src/main/java/com/wxnacy/spring/bean/Screen.java | ||
src/main/java/com/wxnacy/spring/bean/User.java | ||
src/main/java/com/wxnacy/spring/controller/ScreenController.java | ||
src/main/java/com/wxnacy/spring/repository/ScreenRepository.java |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false"> | ||
<output url="file://$MODULE_DIR$/target/classes" /> | ||
<output-test url="file://$MODULE_DIR$/target/test-classes" /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" /> | ||
<excludeFolder url="file://$MODULE_DIR$/target" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-data-jpa:1.5.9.RELEASE" level="project" /> | ||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:1.5.9.RELEASE" level="project" /> | ||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:1.5.9.RELEASE" level="project" /> | ||
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.1.11" level="project" /> | ||
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.1.11" level="project" /> | ||
<orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.25" level="project" /> | ||
<orderEntry type="library" name="Maven: org.slf4j:log4j-over-slf4j:1.7.25" level="project" /> | ||
<orderEntry type="library" scope="RUNTIME" name="Maven: org.yaml:snakeyaml:1.17" level="project" /> | ||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-aop:1.5.9.RELEASE" level="project" /> | ||
<orderEntry type="library" name="Maven: org.springframework:spring-aop:4.3.13.RELEASE" level="project" /> | ||
<orderEntry type="library" name="Maven: org.aspectj:aspectjweaver:1.8.13" level="project" /> | ||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-jdbc:1.5.9.RELEASE" level="project" /> | ||
<orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-jdbc:8.5.23" level="project" /> | ||
<orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-juli:8.5.23" level="project" /> | ||
<orderEntry type="library" name="Maven: org.springframework:spring-jdbc:4.3.13.RELEASE" level="project" /> | ||
<orderEntry type="library" name="Maven: org.hibernate:hibernate-core:5.0.12.Final" level="project" /> | ||
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.3.1.Final" level="project" /> | ||
<orderEntry type="library" name="Maven: org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Final" level="project" /> | ||
<orderEntry type="library" name="Maven: org.javassist:javassist:3.21.0-GA" level="project" /> | ||
<orderEntry type="library" name="Maven: antlr:antlr:2.7.7" level="project" /> | ||
<orderEntry type="library" name="Maven: org.jboss:jandex:2.0.0.Final" level="project" /> | ||
<orderEntry type="library" name="Maven: dom4j:dom4j:1.6.1" level="project" /> | ||
<orderEntry type="library" name="Maven: org.hibernate.common:hibernate-commons-annotations:5.0.1.Final" level="project" /> | ||
<orderEntry type="library" name="Maven: org.hibernate:hibernate-entitymanager:5.0.12.Final" level="project" /> | ||
<orderEntry type="library" name="Maven: javax.transaction:javax.transaction-api:1.2" level="project" /> | ||
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-jpa:1.11.9.RELEASE" level="project" /> | ||
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-commons:1.13.9.RELEASE" level="project" /> | ||
<orderEntry type="library" name="Maven: org.springframework:spring-orm:4.3.13.RELEASE" level="project" /> | ||
<orderEntry type="library" name="Maven: org.springframework:spring-context:4.3.13.RELEASE" level="project" /> | ||
<orderEntry type="library" name="Maven: org.springframework:spring-tx:4.3.13.RELEASE" level="project" /> | ||
<orderEntry type="library" name="Maven: org.springframework:spring-beans:4.3.13.RELEASE" level="project" /> | ||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" /> | ||
<orderEntry type="library" name="Maven: org.slf4j:jcl-over-slf4j:1.7.25" level="project" /> | ||
<orderEntry type="library" name="Maven: org.springframework:spring-aspects:4.3.13.RELEASE" level="project" /> | ||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:1.5.9.RELEASE" level="project" /> | ||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:1.5.9.RELEASE" level="project" /> | ||
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:8.5.23" level="project" /> | ||
<orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-annotations-api:8.5.23" level="project" /> | ||
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-el:8.5.23" level="project" /> | ||
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:8.5.23" level="project" /> | ||
<orderEntry type="library" name="Maven: org.hibernate:hibernate-validator:5.3.6.Final" level="project" /> | ||
<orderEntry type="library" name="Maven: javax.validation:validation-api:1.1.0.Final" level="project" /> | ||
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.3.4" level="project" /> | ||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.8.10" level="project" /> | ||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.8.0" level="project" /> | ||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.8.10" level="project" /> | ||
<orderEntry type="library" name="Maven: org.springframework:spring-web:4.3.13.RELEASE" level="project" /> | ||
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:4.3.13.RELEASE" level="project" /> | ||
<orderEntry type="library" name="Maven: org.springframework:spring-expression:4.3.13.RELEASE" level="project" /> | ||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:1.5.9.RELEASE" level="project" /> | ||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:1.5.9.RELEASE" level="project" /> | ||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:1.5.9.RELEASE" level="project" /> | ||
<orderEntry type="library" scope="TEST" name="Maven: com.jayway.jsonpath:json-path:2.2.0" level="project" /> | ||
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:json-smart:2.2.1" level="project" /> | ||
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:accessors-smart:1.1" level="project" /> | ||
<orderEntry type="library" scope="TEST" name="Maven: org.ow2.asm:asm:5.0.3" level="project" /> | ||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" /> | ||
<orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:2.6.0" level="project" /> | ||
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:1.10.19" level="project" /> | ||
<orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:2.1" level="project" /> | ||
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" /> | ||
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-library:1.3" level="project" /> | ||
<orderEntry type="library" scope="TEST" name="Maven: org.skyscreamer:jsonassert:1.4.0" level="project" /> | ||
<orderEntry type="library" scope="TEST" name="Maven: com.vaadin.external.google:android-json:0.0.20131108.vaadin1" level="project" /> | ||
<orderEntry type="library" name="Maven: org.springframework:spring-core:4.3.13.RELEASE" level="project" /> | ||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:4.3.13.RELEASE" level="project" /> | ||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-devtools:1.5.9.RELEASE" level="project" /> | ||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:1.5.9.RELEASE" level="project" /> | ||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:1.5.9.RELEASE" level="project" /> | ||
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:5.1.44" level="project" /> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<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.wxnacy.spring</groupId> | ||
<artifactId>TMD</artifactId> | ||
<packaging>jar</packaging> | ||
<version>1.0-SNAPSHOT</version> | ||
<name>TMD</name> | ||
<url>http://maven.apache.org</url> | ||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>1.5.9.RELEASE</version> | ||
</parent> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-data-jpa</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-devtools</artifactId> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>mysql</groupId> | ||
<artifactId>mysql-connector-java</artifactId> | ||
</dependency> | ||
</dependencies> | ||
<properties> | ||
<java.version>1.8</java.version> | ||
</properties> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
<!-- <dependencies> --> | ||
<!-- <dependency> --> | ||
<!-- <groupId>org.springframework</groupId> --> | ||
<!-- <artifactId>springloaded</artifactId> --> | ||
<!-- <version>1.2.6.RELEASE</version> --> | ||
<!-- </dependency> --> | ||
<!-- </dependencies> --> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.wxnacy.spring; | ||
|
||
import java.util.Arrays; | ||
|
||
import org.springframework.boot.CommandLineRunner; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.context.ApplicationContext; | ||
import org.springframework.context.annotation.Bean; | ||
|
||
@SpringBootApplication | ||
public class Application { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(Application.class, args); | ||
} | ||
|
||
} |
72 changes: 72 additions & 0 deletions
72
java/TMD/src/main/java/com/wxnacy/spring/UserController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package com.wxnacy.spring; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
public class UserController { | ||
|
||
@Autowired | ||
private UserRepository userRepository; | ||
|
||
@GetMapping("/user") | ||
public List<User> users( | ||
@RequestParam(required=false, defaultValue="wxnacy") String name | ||
) { | ||
List<User> res = userRepository.findByName(name); | ||
return res; | ||
} | ||
|
||
@GetMapping("/user/{id}") | ||
public User user( | ||
@PathVariable Integer id | ||
) { | ||
User user = userRepository.findById(id); | ||
return user; | ||
} | ||
|
||
@PostMapping("/user") | ||
public User create( | ||
@RequestBody Map<String, String> body | ||
) { | ||
User user = new User(body.get("name")); | ||
System.out.println(user.getId()); | ||
User item = userRepository.save(user); | ||
System.out.println(item.getId()); | ||
item = userRepository.save(user); | ||
System.out.println(item.getId()); | ||
item = userRepository.saveAndFlush(user); | ||
System.out.println(item.getId()); | ||
|
||
List<User> users = new ArrayList(); | ||
users.add(new User("haah")); | ||
users.add(new User("ssss")); | ||
// List<User> items = userRepository::save(users); | ||
// for(int i = 0; i < items.size(); i++){ | ||
// System.out.println(items.get(i).getId()); | ||
|
||
// } | ||
|
||
new Thread(new Runnable() { | ||
@Override | ||
public void run() { | ||
System.out.println("Before Java8, too much code for too little to do"); | ||
} | ||
}).start(); | ||
|
||
new Thread( () -> System.out.println("In Java8, Lambda expression rocks !!") ).start(); | ||
|
||
|
||
return item; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.wxnacy.spring; | ||
|
||
import java.util.List; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface UserRepository extends JpaRepository<User, Integer> { | ||
List<User> findByName(String name); | ||
User findById(Integer id); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package com.wxnacy.spring.bean; | ||
|
||
import javax.persistence.CascadeType; | ||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.ManyToOne; | ||
import javax.persistence.JoinColumn; | ||
|
||
@Entity | ||
public class Screen{ | ||
@Id | ||
@GeneratedValue() | ||
private Long id; | ||
private String code; | ||
private String name; | ||
private Long shopId; | ||
private Shop shop; | ||
private String brand; | ||
private String mac; | ||
|
||
|
||
public Screen() { | ||
} | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public void setCode(String code) { | ||
this.code = code; | ||
} | ||
|
||
public String getCode() { | ||
return code; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setShopId(Long shopId) { | ||
this.shopId = shopId; | ||
} | ||
|
||
public Long getShopId() { | ||
return shopId; | ||
} | ||
|
||
public void setMac(String mac) { | ||
this.mac = mac; | ||
} | ||
|
||
public String getMac() { | ||
return mac; | ||
} | ||
|
||
public void setBrand(String brand) { | ||
this.brand = brand; | ||
} | ||
|
||
@ManyToOne(cascade = {CascadeType.MERGE,CascadeType.REFRESH }, optional = true) | ||
@JoinColumn(name="shop_id") | ||
public String getBrand() { | ||
return brand; | ||
} | ||
|
||
public void setShop(Shop shop) { | ||
this.shop = shop; | ||
} | ||
|
||
public Shop getShop() { | ||
return shop; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.wxnacy.spring.bean; | ||
|
||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
|
||
@Entity | ||
public class Shop{ | ||
@Id | ||
@GeneratedValue() | ||
private Long id; | ||
private String code; | ||
private String name; | ||
|
||
|
||
public Shop() { | ||
} | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public void setCode(String code) { | ||
this.code = code; | ||
} | ||
|
||
public String getCode() { | ||
return code; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
} |
Oops, something went wrong.