Sorry For Inconvenience, Site is Under Maintenance. Please Goto HomePage

Spring Boot Framework Fresco Play Handson Solutions

Notes Bureau

Spring Boot Framework Fresco Play Handson Solutions


Disclaimer: The main motive to provide this solution is to help and support those who are unable to do these courses due to facing some issue and having a little bit lack of knowledge. All of the material and information contained on this website is for knowledge and education purposes only.

Try to understand these solutions and solve your Hands-On problems. (Not encourage copy and paste these solutions)




1.Accessing values from application.properties file

Hands-on with application.properties file(20 min)


Spring Boot Framework Fresco Play Handson Solutions

1.1 File Name: application.properties(src/main/resources)


#Put your property here

fresco-course = Spring Boot



2.Welcome to Sorting list of objects.

Sorting list of Candidates

Spring Boot Executable(30 min)



2.1 File Name: Employee.java


package com.example.demo.employee;


public class Employee implements Comparable<Employee> {


private String name;

private int age;

private int exp;

public int getAge() {

return age;

}

public void setAge(int age) {

this.age = age;

}

public int getExp() {

return exp;

}

public void setExp(int exp) {

this.exp = exp;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public Employee(String name, int age, int exp) {

super();

this.name = name;

this.age = age;

this.exp = exp;

}

public Employee() {

}

@Override

public int compareTo(Employee emp) {

//replace your comparator here


return (this.getAge() - emp.getAge());

}

}


2.2 File Name: EmployeeController.java


package com.example.demo.employee;

import java.util.Collections;

import java.util.List;


import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;


@RestController

public class EmployeeController {

@Autowired

private EmployeeService emp;

@RequestMapping("/")

//Put your code here

public List<Employee> getEmpList(){

//Put your code here

List<Employee> e = emp.getEmployees();

Collections.sort(e);

return e;

}

}


2.3 File Name: EmployeeService.java


package com.example.demo.employee;


import java.util.Arrays;


import org.springframework.stereotype.Service;

import java.util.List;

import java.util.ArrayList;


@Service

public class EmployeeService {

public List<Employee> getEmployees() {

//put your code here.

final List<Employee> NB = new ArrayList<>();

NB.add(new Employee("Sandhya",20,0));

NB.add(new Employee("Kemp",24,2));

NB.add(new Employee("Anil",22,3));

NB.add(new Employee("Kumar",30,6));

NB.add(new Employee("Tim",32,7));

return NB;

}

}


3.Welcome to Print the contents of list along with the subList.

My first Spring MVC Application(30 min)




3.1 File Name: ContentController.java


package com.example.demo.content;


import java.util.List;

import org.springframework.web.bind.annotation.RestController;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.RequestMapping;


@RestController

public class ContentController {

//Put your code here.

@Autowired

private ContentService NB;


@RequestMapping("/")

public List<Category> getContentList(){

List<Category> nb = NB.getAllContent();

return nb;

}


}


3.2 File Name: ContentService.java


package com.example.demo.content;


import java.util.Arrays;

import java.util.List;

import java.util.ArrayList;


import org.springframework.stereotype.Service;


@Service

public class ContentService {


public List<Category> NBcategories = new ArrayList<>();

//put your code here.

public List<Category> getAllContent() {


List<Course> NBcourse = new ArrayList<>();

NBcourse.add(new Course(1,"NotesBureau",200,200,1001));

NBcourse.add(new Course(1,"NotesBureau",200,200,1001));

NBcourse.add(new Course(1,"NotesBureau",200,200,1001));


List<Category> NBategories = new ArrayList<>();


NBategories.add(new Category(1001,"NotesBureau","Lets teach and learn",NBcourse));

NBategories.add(new Category(1001,"NotesBureau","Lets teach and learn",NBcourse));

NBategories.add(new Category(1001,"NotesBureau","Lets teach and learn",NBcourse));

return NBategories;

}

}

If you want answers to any of the fresco play courses feel free to ask in the comment section, we will surely help.

2 comments

  1. Can you please try to give me the solution for spring boot api compatible hands on
  2. Can i get solution for spring boot compatible api
Any comments and suggestion will be appreciated.
Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.

Join Telegram Channel

Join Notes Bureau Lets Teach and Learn

Join Telegram Channel
CLOSE ADS
CLOSE ADS