Compare commits
3 Commits
6331a5e5e9
...
f42c332757
| Author | SHA1 | Date | |
|---|---|---|---|
| f42c332757 | |||
| fc79489375 | |||
| 5e6888c904 |
2
Jenkinsfile
vendored
2
Jenkinsfile
vendored
@ -14,7 +14,7 @@ podTemplate(label: label, containers: [
|
|||||||
container('maven') {
|
container('maven') {
|
||||||
stage('Build') {
|
stage('Build') {
|
||||||
sh '''
|
sh '''
|
||||||
mvn clean package -Dmaven.test.skip
|
mvn clean package
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
stage('Archive') {
|
stage('Archive') {
|
||||||
|
|||||||
4
pom.xml
4
pom.xml
@ -40,6 +40,10 @@
|
|||||||
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
|
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.h2database</groupId>
|
||||||
|
<artifactId>h2</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.postgresql</groupId>
|
<groupId>org.postgresql</groupId>
|
||||||
|
|||||||
@ -1,29 +0,0 @@
|
|||||||
package com.example.servicedemo;
|
|
||||||
|
|
||||||
public class Student {
|
|
||||||
private String name;
|
|
||||||
private String className;
|
|
||||||
|
|
||||||
|
|
||||||
public Student(String name, String className) {
|
|
||||||
super();
|
|
||||||
this.name = name;
|
|
||||||
this.className = className;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getClassName() {
|
|
||||||
return className;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setClassName(String className) {
|
|
||||||
this.className = className;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,56 +0,0 @@
|
|||||||
package com.example.servicedemo.controller;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.example.servicedemo.Student;
|
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/api")
|
|
||||||
public class StudentServiceController {
|
|
||||||
|
|
||||||
private static Map<String, List<Student>> schooDB = new HashMap<String, List<Student>>();
|
|
||||||
|
|
||||||
static {
|
|
||||||
schooDB = new HashMap<String, List<Student>>();
|
|
||||||
|
|
||||||
List<Student> lst = new ArrayList<Student>();
|
|
||||||
Student std = new Student("Sajal", "Class IV");
|
|
||||||
lst.add(std);
|
|
||||||
std = new Student("Lokesh", "Class V");
|
|
||||||
lst.add(std);
|
|
||||||
|
|
||||||
schooDB.put("abcschool", lst);
|
|
||||||
|
|
||||||
lst = new ArrayList<Student>();
|
|
||||||
std = new Student("Kajal", "Class III");
|
|
||||||
lst.add(std);
|
|
||||||
std = new Student("Sukesh", "Class VI");
|
|
||||||
lst.add(std);
|
|
||||||
|
|
||||||
schooDB.put("xyzschool", lst);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/getStudentDetailsForSchool/{schoolname}", method = RequestMethod.GET)
|
|
||||||
public List<Student> getStudents(@PathVariable String schoolname) {
|
|
||||||
System.out.println("Getting Student details for " + schoolname);
|
|
||||||
|
|
||||||
List<Student> studentList = schooDB.get(schoolname);
|
|
||||||
if (studentList == null) {
|
|
||||||
studentList = new ArrayList<Student>();
|
|
||||||
Student std = new Student("Not Found", "N/A");
|
|
||||||
studentList.add(std);
|
|
||||||
}
|
|
||||||
return studentList;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -4,6 +4,8 @@ import java.util.Date;
|
|||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "events")
|
@Table(name = "events")
|
||||||
public class Event {
|
public class Event {
|
||||||
@ -12,6 +14,7 @@ public class Event {
|
|||||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
private long id;
|
private long id;
|
||||||
|
|
||||||
|
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||||
@Column(name = "date")
|
@Column(name = "date")
|
||||||
private Date when;
|
private Date when;
|
||||||
|
|
||||||
|
|||||||
21
src/test/resources/application.properties
Normal file
21
src/test/resources/application.properties
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
|
||||||
|
server.port=9098
|
||||||
|
spring.application.name: servicedemo
|
||||||
|
management.security.enabled=false
|
||||||
|
|
||||||
|
spring.datasource.driver-class-name=org.h2.Driver
|
||||||
|
spring.datasource.url=jdbc:h2:mem:db;DB_CLOSE_DELAY=-1
|
||||||
|
spring.datasource.username=sa
|
||||||
|
spring.datasource.password=sa
|
||||||
|
|
||||||
|
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation= true
|
||||||
|
spring.jpa.properties.hibernate.dialect= org.hibernate.dialect.PostgreSQLDialect
|
||||||
|
|
||||||
|
# Hibernate ddl auto (create, create-drop, validate, update)
|
||||||
|
spring.jpa.hibernate.ddl-auto= update
|
||||||
|
|
||||||
|
spring.cloud.consul.token = 4d19eb8c-0e53-3c5b-c479-04b41af55e9d
|
||||||
|
|
||||||
|
spring.cloud.discovery.enabled=false
|
||||||
|
spring.cloud.consul.enabled=false
|
||||||
|
spring.cloud.consul.config.enabled=false
|
||||||
Loading…
Reference in New Issue
Block a user