addresourcehandlers spring boot
Overcoming them is what makes life meaningful I am enjoying Challenges
Saturday, 1 September 2018
Sunday, 26 August 2018
return list of json spring boot rest controller
Let Say we have list of CarDetails Pojo and we want to return them back
@RestController
public class CarDetailController {
@GetMapping("/viewAllCarDetailList")
public List<CarDetail> retrieveAllCarDetails() {
List<CarDetail> contacts = new ArrayList<CarDetail>();
CarDetail objt = new CarDetail();
objt.setCarModel("hyundai");
objt.setSubModel("I10");
CarDetail objt2 = new CarDetail();
objt2.setCarModel("hyundai");
objt2.setSubModel("I20");
contacts.add(objt);
contacts.add(objt2);
return contacts;
}
}
public class CarDetails {
private String carModel;
private String subModel;
// Will haave Setter getter and hash code equls method
//and constructor
}
This JSON will be output:-
[
{
"carModel": "hyundai",
"subModel": "I10"
},
{
"carModel": "hyundai",
"subModel": "I20"
}
]
https://stackoverflow.com/questions/41719142/how-to-return-a-set-of-objects-with-spring-boot
Saturday, 18 August 2018
scala object hello world eclipse example
scala hello world eclipse
object HelloWorldScala {
def main(args: Array[String]) {
println("Hello Scala !!")
}
}
output will be as like bellow
Hello Scala !!
object HelloWorldScala {
def main(args: Array[String]) {
println("Hello Scala !!")
}
}
output will be as like bellow
Hello Scala !!
spark-shell java was unexpected at this time
spark-shell java was unexpected at this time
You can see this issue when your Java home set like following in windows
JAVA_HOME=C:\Program Files (x86)\Java\jdk1.8.0_162\bin
Issue here is space in "Program Files (x86)" If you add double quotes will not work on window 10
"C:\Program Files (x86)\Java\jdk1.8.0_162\bin"
You need to copy Java into outside Program Files (x86) then it should work
JAVA_HOME=C:\java\jdk1.8.0_171\bin
--------------------------------------------------------------------------------------------------
Finally I upgraded my java version to JDK 1.8 for Spark!!!
You can see this issue when your Java home set like following in windows
JAVA_HOME=C:\Program Files (x86)\Java\jdk1.8.0_162\bin
Issue here is space in "Program Files (x86)" If you add double quotes will not work on window 10
"C:\Program Files (x86)\Java\jdk1.8.0_162\bin"
You need to copy Java into outside Program Files (x86) then it should work
JAVA_HOME=C:\java\jdk1.8.0_171\bin
--------------------------------------------------------------------------------------------------
Finally I upgraded my java version to JDK 1.8 for Spark!!!
spark shell cmd not recognized as an internal or external command
spark shell cmd not recognized as an internal or external command
I fixed it after following changes:
There were multiple Java/bin path in the System Path.
So I corrected them to reflect single Java/Bin, which is in sync with JAVA_HOME
Added C:Windows\system32 to System Path Variable.
I fixed it after following changes:
There were multiple Java/bin path in the System Path.
So I corrected them to reflect single Java/Bin, which is in sync with JAVA_HOME
Added C:Windows\system32 to System Path Variable.
Saturday, 14 July 2018
hyperlink in HTML
<!DOCTYPE html>
<html>
<body>
<h2>hyperlink in HTML </h2>
<p><a href="http://localhost:8080/addCarDetails">Visit our AddCarDetails</a></p>
</body>
</html>
<html>
<body>
<h2>hyperlink in HTML </h2>
<p><a href="http://localhost:8080/addCarDetails">Visit our AddCarDetails</a></p>
</body>
</html>
How to Check whether number is even or odd
import java.text.ParseException;
public class TestOddEvenExample {
public static void main(String args[]) throws ParseException {
int x = 24;
oddEvenChecker(x);
int xx = 3;
oddEvenChecker(xx);
}
static void oddEvenChecker(int x) {
if (x % 2 == 0)
System.out.println("You entered an even number." + x);
else
System.out.println("You entered an odd number." + x);
}
}
Friday, 13 July 2018
simple date format in java
simple date format in java example for bellow date format
yyyy-MM-dd HH:mm:ss.SSSSSS.
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
//TODO OutPut should LIKE in this format yyyy-MM-dd HH:mm:ss.SSSSSS.
public class TestDateExample {
public static void main(String args[]) throws ParseException {
SimpleDateFormat changeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSSSS");
java.util.Date temp = changeFormat.parse("2012-07-10 14:58:00.000000");
Date thisDate = changeFormat.parse("2012-07-10 14:58:00.000000");
System.out.println(thisDate);
System.out.println("----------------------------");
System.out.println("After applying formating :");
String strDateOutput = changeFormat.format(temp);
System.out.println(strDateOutput);
}
}
yyyy-MM-dd HH:mm:ss.SSSSSS.
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
//TODO OutPut should LIKE in this format yyyy-MM-dd HH:mm:ss.SSSSSS.
public class TestDateExample {
public static void main(String args[]) throws ParseException {
SimpleDateFormat changeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSSSS");
java.util.Date temp = changeFormat.parse("2012-07-10 14:58:00.000000");
Date thisDate = changeFormat.parse("2012-07-10 14:58:00.000000");
System.out.println(thisDate);
System.out.println("----------------------------");
System.out.println("After applying formating :");
String strDateOutput = changeFormat.format(temp);
System.out.println(strDateOutput);
}
}
Saturday, 7 July 2018
invalid loc header (bad signature)
invalid loc header (bad signature) This error we will get due to bad or corrupt maven dependency.
Solution is Just delete that maven dependency. from .m2 location
Solution is Just delete that maven dependency. from .m2 location
Subscribe to:
Posts (Atom)