dev cases | Java development tutorials
238 FOLLOWERS
In this tutorial you will know, how you can organize efficiently your dependencies in project with multiple modules.
dev cases | Java development tutorials
3y ago
Tutorial describing how to integrate JavaMelody with Spring or Spring Boot 1 application. If we are developing the Spring Boot 2 application, we can use the javamelody-spring-boot-starter as described here. In other case we have to provide own confguration as follows.
Technologies used:
Spring Boot 1.5.22.RELEASE
JDK 1.8
Maven 3
JavaMelody
Project setup
Project dependencies managed by the Maven’s pom.xml configuration file:
<?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:sch ..read more
dev cases | Java development tutorials
3y ago
Tutorial describing how to integrate JavaMelody with Spring Boot 2 application to monitor application health.
Please note that this configuration isn’t compatible with Spring Boot 1 nor plain Spring project. For those project we cannot use the javamelody-spring-boot-starter library with preconfigured JavaMelody beans but should use the javamelody-core dependency and do the configuration ourself like desbribed here.
Technologies used:
Spring Boot 2.2.1.RELEASE
JDK 1.8
Maven 3
JavaMelody
Project setup
Project dependencies managed by the Maven’s pom.xml configuration file:
<?xml version="1 ..read more
dev cases | Java development tutorials
3y ago
In this tutorial we will find out how to find file (by its name) inside the specified directory using different methods and libraries.
Java 6
Finding the file inside directory recursively (including subdirectories), the logic of traversing through the directory structure is written manually:
public File findFilesInFolderRecursively(File checkedFile, String searchedFilename) {
if (checkedFile.getName().equals(searchedFilename)) {
return checkedFile;
}
if (checkedFile.isDirectory()) {
for (File file : checkedFile.listFiles()) {
File foundFile = findFilesI ..read more
dev cases | Java development tutorials
3y ago
In this tutorial we will find out how to list all files and folders in the specified directory.
Java 6
Listing all the files and directories in the specified directory (flat structure):
public void listFilesForFolder(File directory) {
File[] files = directory.listFiles();
for (File file : files) {
System.out.println(file);
}
}
Listing all files and directories recursively (including subdirectories):
public void listFilesForFolderRecursively(File directory) {
for (File file : directory.listFiles()) {
if (file.isDirectory()) {
listFilesForFolderRecu ..read more
dev cases | Java development tutorials
3y ago
In this tutorial we will check java solutions of conversion Iterable to Collection.
Java solutions 1. for loop
Simple solution that iterates over the elements and adds them into the collection one by one:
List<T> list = new ArrayList<T>();
for (T element: iterable) {
list.add(element);
}
2. while loop
In this case we use directly the iterator’s methods (hasNext and get) to control iteration over the elements:
List<T> list = new ArrayList<T>();while (iterator.hasNext()) {list.add(iterator.next());}
3. foreach
The Java 8 foreach method:
List<T> list = new A ..read more
dev cases | Java development tutorials
3y ago
Tutorial describing how to create the simple CRUD (Create Read Update Delete) application using Spring Boot, Freemarker template engine and H2 as embedded database.
Technologies used:
Spring Boot 2.1.7.RELEASE
JDK 1.8
Maven 3
Freemarker
JQuery
Spring Data JPA
H2 database
Project setup
Project dependencies managed by the Maven’s pom.xml configuration file:
<?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.or ..read more
dev cases | Java development tutorials
3y ago
Tutorial describing how to create the simple CRUD (Create Read Update Delete) application using Spring Boot, JSP template engine and H2 as embedded database.
Technologies used:
Spring Boot 2.1.7.RELEASE
JDK 1.8
Maven 3
JSP
Spring Data JPA
H2 database
Project setup
Project dependencies managed by the Maven’s pom.xml configuration file:
<?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 ..read more
dev cases | Java development tutorials
3y ago
Tutorial describing how to create the simple Hello World application using Spring Boot and Freemarker template engine.
Technologies used:
Spring Boot 2.1.7.RELEASE
JDK 1.8
Maven 3
Freemarker
Project setup
Project dependencies managed by the Maven’s pom.xml configuration file:
<?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> ..read more
dev cases | Java development tutorials
3y ago
Tutorial describing how to create the simple Hello World application using Spring Boot and JSP.
Technologies used:
Spring Boot 2.1.7.RELEASE
JDK 1.8
Maven 3
JSP
Project setup
Project dependencies managed by the Maven’s pom.xml configuration file:
<?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>
<gr ..read more
dev cases | Java development tutorials
3y ago
The problem usually occurs when you don’t have a possibility to run tests by your IDE (where there is a built in support of debugger), but you have to debug the failing test remotely. The command we should use should be:
mvn -Dmaven.surefire.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -Djava.compiler=NONE" Test
The property maven.surefire.debug of the Surefire Plugin configures the behaviour of the debugger during the execution the test phase. The above command use the Java Debug Wire Protocol (JDWP) to connect to the maven java process. Then we can use the j ..read more