Compare commits

..

No commits in common. "f42c332757bb859e3dfd0bc665c741245b24d9f7" and "6331a5e5e9f7692e3658f874639481943a39a395" have entirely different histories.

6 changed files with 86 additions and 29 deletions

2
Jenkinsfile vendored
View File

@ -14,7 +14,7 @@ podTemplate(label: label, containers: [
container('maven') {
stage('Build') {
sh '''
mvn clean package
mvn clean package -Dmaven.test.skip
'''
}
stage('Archive') {

View File

@ -40,10 +40,6 @@
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>

View File

@ -0,0 +1,29 @@
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;
}
}

View File

@ -0,0 +1,56 @@
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;
}
}

View File

@ -4,8 +4,6 @@ import java.util.Date;
import javax.persistence.*;
import com.fasterxml.jackson.annotation.JsonFormat;
@Entity
@Table(name = "events")
public class Event {
@ -14,7 +12,6 @@ public class Event {
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Column(name = "date")
private Date when;

View File

@ -1,21 +0,0 @@
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