Комментарии:
I'm using jersey v2.29
I'm getting 500 error when return java object as XML... but no any error on console.. But i can get string if return string
what are the prerequisites for restful service in java
Ответитьi am getting error 404 --the origin server did not find a current representation for the target resource or is not willing to disclose that one exists
ОтветитьThank you sir for this tutorial
ОтветитьWhile running time showing (java.lang.ClassNotFoundException:jakarta.servlet.filter) but I have added related dependencies also still not solving the problem...
Ответитьi dont understand that why he have to talk about servlet in everything instead of the topic of the tutorial,.I was referring spring boot there also he lecture about servlet n all , then i switched to this here also the same thing, everybody here is not from software background here, Please understand this, I have learnt java only with the help of telusko, but while learning advance , its disturbing that he talks more about the topics which everybody might not understand
ОтветитьPlease Which app do you use for your screen recording?
Ответитьthis is so cringe-worthy
ОтветитьCan you provide tutorials in Telugu step by step ...from spring framework
Ответитьthat is tricky . thanks for successfully video
Ответитьnice content
Ответитьnice comment
Ответить"because I love Jason"🙃
Ответить@RestController
@RequestMapping(value = "/employee")
public class EmployeeController {
@Autowired
private EmployeeRep employeeRep;
@GetMapping("/one")
public Map<String, Long> maleAndFemaleEmployees() {
List<Employee> noOfMaleAndFemaleEmployees = employeeRep.findAll();
Map<String, Long> collect = noOfMaleAndFemaleEmployees.stream()
.collect(Collectors.groupingBy(Employee::getGender, Collectors.counting()));
return collect;
}
@GetMapping("/two")
public Stream<String> findAllEmpDeptDistinct() {
List<Employee> findAll = employeeRep.findAll();
Stream<String> distinct = findAll.stream().map(app -> app.getDept()).distinct();
return distinct;
}
@GetMapping("/three")
public Map<String, Double> avgAgeOfMaleAndFemale() {
List<Employee> avgAgeOfMaleAndFemaleEmployees = employeeRep.findAll();
Map<String, Double> collect = avgAgeOfMaleAndFemaleEmployees.stream()
.collect(Collectors.groupingBy(Employee::getGender, Collectors.averagingDouble(Employee::getAge)));
return collect;
}
@GetMapping("/four")
public Optional<Employee> highPaidEmployee() {
List<Employee> highestPaidDetailFull = employeeRep.findAll();
Optional<Employee> max = highestPaidDetailFull.stream()
.collect(Collectors.maxBy(Comparator.comparingDouble(Employee::getSalary)));
return max;
}
@GetMapping("/five")
public ResponseEntity<String> highestPaidEmployee() {
List<Employee> highestPaid = employeeRep.findAll();
Optional<Employee> max = highestPaid.stream().max(Comparator.comparing(Employee::getSalary));
if (max.isPresent()) {
Employee employee = max.get();
String name = employee.getName();
String department = employee.getDept();
String response = "Highest Paid Employee: " + name + " (Department: " + department + ")";
return ResponseEntity.ok(response);
} else {
return ResponseEntity.notFound().build();
}
}
@GetMapping("/six")
public Stream<String> joinedafter2015() {
List<Employee> findAll = employeeRep.findAll();
Stream<String> map = findAll.stream().filter(te -> te.getYearOfJoining() > 2015).map(Employee::getName);
return map;
}
@GetMapping("/seven")
public Map<String, Long> employeeCountByDepartment() {
List<Employee> countByDepartment = employeeRep.findAll();
Map<String, Long> collect = countByDepartment.stream()
.collect(Collectors.groupingBy(Employee::getDept, Collectors.counting()));
return collect;
}
@GetMapping("/eight")
public Map<String, Double> avgSalaryOfDepartments() {
List<Employee> avgSalaryOfDepts = employeeRep.findAll();
Map<String, Double> collect = avgSalaryOfDepts.stream()
.collect(Collectors.groupingBy(Employee::getDept, Collectors.averagingDouble(Employee::getSalary)));
return collect;
}
@GetMapping("/nine")
public Optional<Employee> youngestMaleEmployeeInProductDevelopment() {
List<Employee> youngestMaleEmployeeInProductDeve = employeeRep.findAll();
Optional<Employee> max = youngestMaleEmployeeInProductDeve.stream()
.filter(te -> te.getGender().equals("Male") && te.getDept().equals("Product Development"))
.min(Comparator.comparing(Employee::getAge));
return max;
}
@GetMapping("/ten")
public Optional<Employee> seniorMostEmployee() {
List<Employee> seniorEmployee = employeeRep.findAll();
Optional<Employee> collect = seniorEmployee.stream()
.collect(Collectors.minBy(Comparator.comparing(Employee::getYearOfJoining)));
return collect;
}
@GetMapping("/eleven")
public Map<String, Long> countMaleFemaleEmployeesInSalesMarketing() {
List<Employee> countMaleFemaleEmpInSalesMarketing = employeeRep.findAll();
Map<String, Long> collect = countMaleFemaleEmpInSalesMarketing.stream()
.filter(te -> te.getDept().equals("Sales And Marketing"))
.collect(Collectors.groupingBy(Employee::getGender, Collectors.counting()));
return collect;
}
@GetMapping("/twelve")
public Map<String, Double> avgSalaryOfMaleAndFemaleEmployees() {
List<Employee> avgSalaryOfMaleAndFemaleEmp = employeeRep.findAll();
Map<String, Double> collect = avgSalaryOfMaleAndFemaleEmp.stream()
.collect(Collectors.groupingBy(Employee::getGender, Collectors.averagingDouble(Employee::getSalary)));
return collect;
}
@GetMapping("/thirteen")
public Map<String, List<String>> employeeListByDepartment() {
List<Employee> findAll = employeeRep.findAll();
Map<String, List<String>> collect = findAll.stream().collect(
Collectors.groupingBy(Employee::getDept, Collectors.mapping(Employee::getName, Collectors.toList())));
return collect;
}
@GetMapping("/fourteen")
public String employeeSalarySumAndAvg() {
List<Employee> empSalarySumAndAvg = employeeRep.findAll();
DoubleSummaryStatistics collect = empSalarySumAndAvg.stream()
.collect(Collectors.summarizingDouble(Employee::getSalary));
return "Total Salary = " + collect.getSum() + ", Average Salary = " + collect.getAverage();
}
@GetMapping("/fifteen")
public ResponseEntity<String> partitionEmployeesByAge() {
List<Employee> partitionEmployeesByAge25OldAnd25Young = employeeRep.findAll();
Map<Boolean, List<Employee>> collect = partitionEmployeesByAge25OldAnd25Young.stream()
.collect(Collectors.partitioningBy(te -> te.getAge() > 25));
Set<Entry<Boolean, List<Employee>>> entrySet = collect.entrySet();
String olderEmployeesResponse = "Employees older than 25 years: ";
String youngerEmployeesResponse = "Employees younger than or equal to 25 years: ";
for (Entry<Boolean, List<Employee>> entry : entrySet) {
List<Employee> list = entry.getValue();
for (Employee employee : list) {
String employeeName = employee.getName() + ", ";
if (entry.getKey()) {
olderEmployeesResponse += employeeName;
} else {
youngerEmployeesResponse += employeeName;
}
}
}
String finalResponse = olderEmployeesResponse + "\n" + youngerEmployeesResponse;
return ResponseEntity.ok(finalResponse);
}
@GetMapping("/sixteen")
public ResponseEntity<String> oldestEmployee() {
List<Employee> oldestEmp = employeeRep.findAll();
Optional<Employee> max = oldestEmp.stream().max(Comparator.comparing(Employee::getAge));
if (max.isPresent()) {
Employee employee = max.get();
String dept = employee.getDept();
int age = employee.getAge();
String response1 = "Department : " + dept;
String response2 = "Age : " + age;
String responseBody = response1 + "\n" + response2;
return ResponseEntity.ok(responseBody);
} else {
return ResponseEntity.notFound().build(); // Or any appropriate response for no employees found
}
}
@GetMapping("/seventeen")
public List<String> findAllEmpNamesStartWithA() {
List<Employee> findAll = employeeRep.findAll();
List<String> collect = findAll.stream().filter(te -> te.getName().startsWith("A")).map(Employee::getName)
.collect(Collectors.toList());
return collect;
}
@GetMapping("/eighteen")
public String findAllEmpDeptCount() {
List<Employee> findAll = employeeRep.findAll();
long count = findAll.stream().map(app -> app.getDept()).distinct().count();
return "Total Department : - " + count;
}
@GetMapping("/ninteen")
public String findAllEmpCount() {
List<Employee> allEmpCount = employeeRep.findAll();
Long count = allEmpCount.stream().collect(Collectors.counting());
return "Total Employees: " + count;
}
}
In this video details of RestAPI is just 10% and remaining 90% consist of jersey project creation, Spring project creation, jdbc etc.
ОтветитьAwesome explanation, seeing this in 2023
ОтветитьHi scuse me for my english. I tried to follow the tutorial but this error appears as soon as I invoke the rest "java.lang.NoClassDefFoundError: jakarta/servlet/Filter".
Tomcat 8 and java 1.8
The configuration is in the pom:
<properties>
<jersey.version>3.1.3</jersey.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<war.mvn.plugin.version>3.4.0</war.mvn.plugin.version>
</properties>
<dependencies>
<dependencies>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<!-- use the following artifactId if you don't need servlet 2.x compatibility -->
<!-- artifactId>jersey-container-servlet</artifactId -->
</dependency>
<dependencies>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
</dependency>
<!-- uncomment this to get JSON support
<dependencies>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-binding</artifactId>
</dependency>
-->
</dependencies>
web.xml:
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.telusko.demorest</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/webapi/*</url-pattern>
</servlet-mapping>
Help me Thaks
I am using tomcat10 and jersey version 3.1.3 but not able to avoid this error - SEVERE: MessageBodyWriter not found for media type=application/xml, type=class com.jersey.demorest.Alien, genericType=class com.jersey.demorest.Alien.
ОтветитьYou helped me so much
Ответитьthe XmlRootElement annotation is not working
Ответитьany help
ОтветитьThank you so much for your very useful videos.. Keep up the good work !
Ответить❤
ОтветитьSir please share video on Selenium Webdriver, TestNg,Jenkins, Maven, RestAssured
Ответитьplease update this video quality is bad
ОтветитьYour explanation is great, but I have a question: how can I build a front-end for a web page using this data?
Ответить❤ You made this complex topic so easy. Thank you!!
Ответитьjava.lang.ClassNotFoundException: jakarta.servlet.Filter
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1407)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1215)
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2478)
at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:870)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1371)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1215)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:538)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:519)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:149)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1070)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1010)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4957)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5264)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:919)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:835)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:919)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:263)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:432)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:927)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:772)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:345)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:476) I am getting this error when i try to run the application how can i eliminate this . I tried so many times but error not rectified please Solve this Error
What do we have to learn before learning rest API? Is having knowledge on java is enough for learning rest api
ОтветитьI get this error. Can anyone guide me how to solve this,
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
Can you please share the source code for this project
Ответитьwhy my pom.xml showing error in first line
please solve it sir
Amazing! sir
ОтветитьJun 13, 2024 11:03:11 AM org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor aroundWriteTo
SEVERE: MessageBodyWriter not found for media type=application/xml, type=class com.RestDemo.Student, genericType=class com.RestDemo.Student.
i keep having this error just just can't fix it, i tried changing dependencies but it just dosen't work, please help
For people stuck at 41.10, copy paste below lines in pom.xml
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.4</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>4.0.0</version>
</dependency>
if anyone facing an exception of class not found for sql driver
set url as follows
"jdbc:mysql://localhost:3306/{your-database-name}?useSSL=false&serverTimezone=UTC";
set usessl = false and then run it
unable to find jersey in maven project help!!
🥲
Aliens Assemble!!
ОтветитьHello sir can you update this project on you git repo, I searched but it is not available.
Ответитьsir i just want to confirm is this playlist video are good for learning today , as you can see i am 5 year late to learn about java, restapi, springboot , many updates had done in these languages, i am little bit confuse because as i do according to your videos many option are not found many error come , i don't found exact way to learn about restapi
Ответить