Hello guys, Data types are first few things you should learn when you start learning a programming language and when it comes to learn Java, there are 8 primitive data types which you should know. These are divided into three categories, numeric, text, and boolean values. Numeric data types can be further divided into two like natural numbers and floating pointing numbers. But, Before we get to a list of the 10 examples of primitive data types in Java, let me tell you a little bit more about what the primitive data types are. There are essentially 8 primitive data types in Java. They are int, byte, short, long, float, double, boolean, and char. The primitive data types are not considered objects and represent raw values. These primitive data types are also stored directly on the stack.
Learn Java and Programming through articles, code examples, and tutorials for developers of all levels.
How to write to a File with try-with-resource in Java? Example Tutorial
How to get the first and last item in an array in Java? Example Tutorial
Difference between array and Hashtable or HashMap in Java
A couple of days back someone asked me about the difference between an array and a hashtable, though this is a generic data structure and programming question, I'll answer it from both a general programming perspective as well on Java perspective where Hashtable is not just a data structure but also a class from Java Collection API. Even though both array and hashtable data structure are intended for fast search i.e. constant time search operation also known as O(1) search, the fundamental difference between them is that array require an index while hash table requires a key which could be another object.
How to replace Anonymous Class to Lambda Expression in Java 8? Example Tutorial
Hello guys, you may be thinking why I am talking about Anonymous class now when many Java programmers have already switched to Java 8 and many have already moved on from Anonymous class to Lambda expression in? Well, I am doing it because I am seeing many Java programmers who find it difficult to write and read code using lambda expression in new Java 8 way. It's also my own experience that if you know the problem first, you can better understand the solution (lambda expression). Some of you might remember, the opening scene of MI 2 (Mission Impossible 2), when Nekhorovich says to Dimitri that "Every search for a hero must begin with something that every hero requires, a villain. Therefore, in our search for a hero, Belairiform, we created the monster, Chimera".
Java FileReader + BufferedReader Example
How to use @JsonCreator and @JsonPropertOrder Jackson JN Annotation in Java? Examples
Top 5 Functional Interface Every Java Developer Should Learn
Hello guys, functional interface in Java are an important concept but not many developer pay enough attention to them. They learn lambda and method reference but the functional interface from java.util.function package. While its not really possible to learn all the functional interfaces on that package but you can learn a few more commonly used ones like Predicate, Supplier, Consumer etc and that's what you will learn in this article. But, before we get to the top 5 functional interfaces that every Java developer should learn, let me tell you a bit about what Java really is.
Difference between Class and Object in Java? Example
How to convert List Of of Object to Map of Object (key, value) In Java? Example Tutorial
What is WeakHashMap in Java? HashMap vs WeakHashMap Example Tutorial
Hello friends, we are here today again on our journey to Java. I hope everyone is fine and ready to board our train of knowledge. Today we are gonna learn something very interesting and very exciting. Today's topic will definitely be very useful in coding and programming. This topic would surely decrease your time complexity, and space requirements for any task very significantly :p So what's the wait? Let's start!
JDBC - Difference between PreparedStatement and Statement in Java? Answer
Can you make a class static in Java? Example
Difference between Fixed and Cached Thread pool in Java Executor Famework
Difference in Method Overloading, Overriding, Hiding, Shadowing and Obscuring in Java and Object-Oriented Programming?
Top 30 Gradle Interview Questions Answers for Experienced Java Developers
Difference between Proxy and Decorator Pattern in Java
[Solved] How to find the Longest common prefix in Array of String in Java? Example Tutorial
How to check if a node exists in a binary tree or not in Java? Example Tutorial
10 Tools Every Software Engineer Should Learn In 2024
Hello guys, as a software engineer, staying up-to-date with the latest tools and technologies is essential to your success and one way to keep yourself up-to-date is to learn new framework, libraries and tools. Earlier, I have shared 5 Java Frameworks to learn in 2024 and in this article, we will introduce you to 10 tools that every software engineer should learn in 2024. The list includes, both essential and advanced tools from Git and Docker to TypeScript and GraphQL, which you will need in your day to day development, particularly on web development.
10 examples of crontab commands in Linux
5 Difference between Iterator and ListIterator in Java?
HelloWorld Program in Java with Example
Difference between GenericServlet vs HttpServlet in Servlet JSP - J2EE question
How to iterate over HashSet in Java - loop or traverse Example
In our last Java collection tutorial, we have seen How to iterate over ArrayList in Java and in this tutorial we will see How to iterate over HashSet in Java. There are two ways to iterate, loop or traverse over HashSet in Java, first using advanced for-each loop added on Java 5 and second using Iterator which is a more conventional way of iterating over HashSet in Java. Now questions are When should you use for loop and when Iterator is an appropriate option. Well I usually use for loop If I only read from HashSet and doesn't remove any element, while Iterator is preferred approach. You should not remove elements from HashSet while iterating over it in for loop, Use Iterator to do that.
How to Fix java.lang.VerifyError: Expecting a stack map frame at branch target 14 in method at offset JDK 7 [Solved]
When to throw and catch Exception in Java? [Best Practice]
How to Fix java.sql.BatchUpdateException: Error converting data type float to numeric - Java + SQL Server
How to Fix SQLServerException: The index is out of range? JDBC Example
How to deal with java.lang.NullPointerExceptionin Java? Cause, Solution, and Tips to avoid NPE
How to solve java.sql.BatchUpdateException: String or binary data would be truncated in Java JDBC? [Solution]
How to deal with Unsupported major.minor version 55.0, 57,0, 60.0, 61.0 in Java + Eclipse + Linux [Solution]
How to Fix java.lang.NoClassDefFoundError: org/dom4j/DocumentException [Solution]
[Solved] Exception in thread "main" java.lang.IllegalStateException during Iterator.remove() in Java
How to use DROP command to remove tables in Oracle, MySQL and SQL Server
[Solved] Caused by: java.sql.SQLSyntaxErrorException: ORA-01722: invalid number in Java and Oracle
10 Essential SQL Commands and Functions Every Developer should learn
How to convert String to Integer SQL and Database? MySQL, Oracle, SQL server and PostgreSQL Example
Hello guys, if you are wondering how to convert VARCHAR to String in SQL then you are at the right place. In this article, we will cover various techniques to convert String to Integer in all databases - MySQL, Oracle, SQL server and PostgreSQL. To perform tasks or correlations or change between information in a SQL Server data set, the SQL information kinds of those values should coordinate. At the point when the SQL information types are unique, they will go through a cycle called type-projecting. The transformation of SQL information types, in this cycle, can be implied or unequivocal.
What is Normalization in SQL? 1NF, 2nd NF, 3rd NF and BCNF Example Tutorial
Top 20 AWS Interview Questions Answers for Developers and DevOps Engineers
Top 51 JavaScript Interview Questions for 1 to 2 Years Experienced Developers
Top 50 Advanced Java Garbage Collection and Performance Interview Questions and Answers
Top 27 Spring Security Interview Questions Answers for Java Developers
What is Blocking Deque in Java? How and When to use BlockingDeque? Example Tutorial
How to find 2nd, 3rd or kth element from end in linked list in Java? Example [Solved]
10 Examples of an Array in Java
3 Examples of flatMap() of Stream in Java
Hello guys, if you are doing Java development then you must have come across the flatMap() method on Stream and Optional Class. The flatMap() method is extension of map() function as it does both flattening and mapping (or transformation) instead of just transformation done by map() method. I have explained the difference between map() and flatMap() earlier in detail, but just to revise, let's revisit it. If you have a list of String e.g. {"credit", "debit", "master", "visa"} then you can use the map() method to get a list of integer where each value is length of corresponding String e.g. list.stream().map(s -> s.length()) will produce {6, 5, 6, 4}. This is called transformation because you have transformed an stream of String to a Stream of integer.
How to fix cannot determine embedded database driver class for database type NONE
Hello and welcome to the blog post. Today we are going to take a look at a frequently encountered problem in Spring Boot Application. If you are reading this, I'm going to assume that you saw the problem "Cannot determine embedded database driver class for database type NONE" while executing a Spring Boot application. We will understand, when this error appears. For this we will create a simple Spring Boot project as shown below. It demonstrates how I encountered the problem "Cannot determine embedded database driver class for database type NONE".
Write a Program to Find Sum of Digits in Java
How to use Multiple Catch block for Exception handling in Java? Example Tutorial
How to format Date in Java - SimpleDateFormat Example
Difference between URL, URI and URN - Interview Question
How to traverse iterate or loop ArrayList in Java
How to use Java Enum in Switch Case Statement - Exampel Tutorial
What is CopyOnWriteArrayList in Java - Example Tutorial
Difference between Error vs Exception in Java - Interview question
Java program to get SubList from ArrayList - Example
Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean
Hello and welcome to the blog post. In this post, we are about to take a look at how to fix the ‘unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean’ in the spring boot application. Let’s understand how to fix this error. But before we dig deep into this issue. Let’s first have a look at when this error appears.
Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean
The error appears with the following stack trace.
Exception in thread “main” org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:140)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:476)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:124)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:658)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:355)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:920)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:909)
at Application.main(Application.java:17)
Caused by: org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getEmbeddedServletContainerFactory(EmbeddedWebApplicationContext.java:190)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:163)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:137)
… 7 more
Now, let's see some code to understand when this error comes and how to fix it:
SpringBootPracticeApplication.java
package com.practice.springboot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootConfiguration;
@SpringBootConfiguration
public class SpringBootPracticeApplication {
public static void main(String[] args) {
SpringApplication.run(SpringBootPracticeApplication.class, args);
}
}
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.practice</groupId>
<artifactId>spring-boot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Spring Boot Practice</name>
<description>Spring Boot Practice Project</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<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>
</dependencies>
</project>
As you can see from the above program, we have a very simple spring boot project that fails to run as intended. There are a couple of possible solutions to this program. These approaches are discussed below.
How to fix this error?
First of all you need to ensure that your main class has the @SpringBootApplication annotation.
The @SpringBootApplication annotation is comparable to the @EnableAutoConfiguration, @ComponentScan, and @Configuration annotations with their default properties, i.e., allow adding new beans to the context or importing more configuration classes.
SpringBootPracticeApplication.java -- updated
package com.practice.springboot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringBootPracticeApplication {
public static void main(String[] args) {
SpringApplication.run(SpringBootPracticeApplication.class, args);
}
}
If you have followed the above step or your starter file already contains @SpringBootApplication, you need to make sure your pom.xml file also includes the spring-boot-starter-web or spring-boot-starter-tomcat dependencies, as demonstrated in the example below.
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.practice</groupId>
<artifactId>spring-boot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Spring Boot Practice</name>
<description>Spring Boot Practice Project</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<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>
<!-- Add spring-boot-starter-web or spring-boot-starter-tomcat -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
<!-- Add spring-boot-starter-web or spring-boot-starter-tomcat -->
</dependencies>
</project>
After following the above two approaches, the error finally disappeared and the spring application start successfully as shown from the console.
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.0.4)
2023-03-09T09:46:05.540+05:00 INFO 40009 --- [ main] c.p.s.SpringBootPracticeApplication : Starting SpringBootPracticeApplication using Java 19.0.1 with PID 40009 (/home/muhammad/IdeaProjects/spring-boot/target/classes started by muhammad in /home/muhammad/IdeaProjects/spring-boot)
2023-03-09T09:46:05.545+05:00 INFO 40009 --- [ main] c.p.s.SpringBootPracticeApplication : No active profile set, falling back to 1 default profile: "default"
2023-03-09T09:46:06.501+05:00 INFO 40009 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2023-03-09T09:46:06.509+05:00 INFO 40009 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2023-03-09T09:46:06.510+05:00 INFO 40009 --- [ main] o.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/10.1.5]
2023-03-09T09:46:06.585+05:00 INFO 40009 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2023-03-09T09:46:06.585+05:00 INFO 40009 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 972 ms
2023-03-09T09:46:06.964+05:00 INFO 40009 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2023-03-09T09:46:06.972+05:00 INFO 40009 --- [ main] c.p.s.SpringBootPracticeApplication : Started SpringBootPracticeApplication in 1.927 seconds (process running for 2.661)
Conclusion
That's all about how to fix "Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean" error in Spring Boot. . The main subject of this post is the Spring Boot problem Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.What Java developer Should Know about Object and java.lang.Object
Difference between transient vs volatile variable or modifier in Java
What is the difference between transient and volatile variables or modifiers in Java is one of the most common Serialization Interview Questions in Java. Though volatile variables are not related to Serialization at all, this question is mostly asked in conjunction with other Serialization questions. Both transient and volatile modifiers are completely different from each other. In fact, this question is as popular as Serializable vs Externalizable in Java. The main difference between transient vs volatile variables is that transient variables are not serialized during the Serialization process in Java while volatile variables are used to provide alternative synchronization in Java.
20 EJB 3.0 Interview Questions and Answers - Java J2EE
Is it Possible to take Spring Professional v5.0 Certification without the Official Training course?
Update: Vmware have reversed the decision made by Pivotal and now Spring core training is mandatory. It's an unfortunate decision as this training is costly and cost around USD 950 but may different cost in India or other region like it used to have 50K INR with partners like Springpeople. If you can afford it's definitely worth it and many people expense this cost on their companies training budget. Btw, if you already hold a spring certificate then you can also update it without going through this mandatory training and just passing the Spring professional certification exam.
Autoboxing, Enum, Generics, Varargs methods - Java 5 Features Quick Overview
Java 5 introduces Autoboxing, Generics, varargs and Enum along with several other features and improvement. It's been few years when Java programming language was enhanced with these features but still Java programmer thing Autoboxing, Enum, Generics or Variable arguments as an advanced feature and afraid to learn them. They are very much part of Java fundamentals just like Abstraction, Inheritance, Encapsulation and Polymorphism are part of Object oriented programming concepts. It's important to understand what are these feature and How to use them, even if you don't use them in your code, you may have to work on someone else code which is written in Java 5 and uses Generics Collection, Autoboxing quite frequently.