org.apache.poi
diff --git a/pdf/src/main/java/com/baeldung/pdf/PDF2HTMLExample.java b/pdf/src/main/java/com/baeldung/pdf/PDF2HTMLExample.java
index 0d38208bab..1fdf07a05f 100644
--- a/pdf/src/main/java/com/baeldung/pdf/PDF2HTMLExample.java
+++ b/pdf/src/main/java/com/baeldung/pdf/PDF2HTMLExample.java
@@ -1,6 +1,8 @@
package com.baeldung.pdf;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Writer;
@@ -10,14 +12,21 @@ import javax.xml.parsers.ParserConfigurationException;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.fit.pdfdom.PDFDomTree;
+import com.itextpdf.text.Document;
+import com.itextpdf.text.DocumentException;
+import com.itextpdf.text.pdf.PdfWriter;
+import com.itextpdf.tool.xml.XMLWorkerHelper;
+
public class PDF2HTMLExample {
- private static final String FILENAME = "src/main/resources/pdf.pdf";
+ private static final String PDF = "src/main/resources/pdf.pdf";
+ private static final String HTML = "src/main/resources/html.html";
public static void main(String[] args) {
try {
- generateHTMLFromPDF(FILENAME);
- } catch (IOException | ParserConfigurationException e) {
+ generateHTMLFromPDF(PDF);
+ generatePDFFromHTML(HTML);
+ } catch (IOException | ParserConfigurationException | DocumentException e) {
e.printStackTrace();
}
}
@@ -32,4 +41,12 @@ public class PDF2HTMLExample {
pdf.close();
}
}
+
+ private static void generatePDFFromHTML(String filename) throws ParserConfigurationException, IOException, DocumentException {
+ Document document = new Document();
+ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("src/output/html.pdf"));
+ document.open();
+ XMLWorkerHelper.getInstance().parseXHtml(writer, document, new FileInputStream(filename));
+ document.close();
+ }
}
diff --git a/pdf/src/main/java/com/baeldung/pdf/PDF2ImageExample.java b/pdf/src/main/java/com/baeldung/pdf/PDF2ImageExample.java
index 00778d16c1..69f5d9731f 100644
--- a/pdf/src/main/java/com/baeldung/pdf/PDF2ImageExample.java
+++ b/pdf/src/main/java/com/baeldung/pdf/PDF2ImageExample.java
@@ -1,24 +1,36 @@
package com.baeldung.pdf;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URL;
+
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.rendering.ImageType;
import org.apache.pdfbox.rendering.PDFRenderer;
import org.apache.pdfbox.tools.imageio.ImageIOUtil;
-import java.awt.image.BufferedImage;
-import java.io.File;
-import java.io.IOException;
+import com.itextpdf.text.BadElementException;
+import com.itextpdf.text.Document;
+import com.itextpdf.text.DocumentException;
+import com.itextpdf.text.Image;
+import com.itextpdf.text.pdf.PdfWriter;
public class PDF2ImageExample {
- private static final String FILENAME = "src/main/resources/pdf.pdf";
-
+ private static final String PDF = "src/main/resources/pdf.pdf";
+ private static final String JPG = "http://cdn2.baeldung.netdna-cdn.com/wp-content/uploads/2016/05/baeldung-rest-widget-main-1.2.0";
+ private static final String GIF = "https://media.giphy.com/media/l3V0x6kdXUW9M4ONq/giphy";
+
public static void main(String[] args) {
try {
- generateImageFromPDF(FILENAME, "png");
- generateImageFromPDF(FILENAME, "jpeg");
- generateImageFromPDF(FILENAME, "gif");
- } catch (IOException e) {
+ generateImageFromPDF(PDF, "png");
+ generateImageFromPDF(PDF, "jpeg");
+ generateImageFromPDF(PDF, "gif");
+ generatePDFFromImage(JPG, "jpg");
+ generatePDFFromImage(GIF, "gif");
+ } catch (IOException | DocumentException e) {
e.printStackTrace();
}
}
@@ -32,4 +44,19 @@ public class PDF2ImageExample {
}
document.close();
}
+
+ private static void generatePDFFromImage(String filename, String extension)
+ throws IOException, BadElementException, DocumentException {
+ Document document = new Document();
+ String input = filename + "." + extension;
+ String output = "src/output/" + extension + ".pdf";
+ FileOutputStream fos = new FileOutputStream(output);
+ PdfWriter writer = PdfWriter.getInstance(document, fos);
+ writer.open();
+ document.open();
+ document.add(Image.getInstance((new URL(input))));
+ document.close();
+ writer.close();
+ }
+
}
diff --git a/pdf/src/main/java/com/baeldung/pdf/PDF2TextExample.java b/pdf/src/main/java/com/baeldung/pdf/PDF2TextExample.java
index c5880a4e91..7965152234 100644
--- a/pdf/src/main/java/com/baeldung/pdf/PDF2TextExample.java
+++ b/pdf/src/main/java/com/baeldung/pdf/PDF2TextExample.java
@@ -1,6 +1,9 @@
package com.baeldung.pdf;
+import java.io.BufferedReader;
import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
@@ -10,14 +13,24 @@ import org.apache.pdfbox.pdfparser.PDFParser;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.text.PDFTextStripper;
+import com.itextpdf.text.Document;
+import com.itextpdf.text.DocumentException;
+import com.itextpdf.text.Element;
+import com.itextpdf.text.Font;
+import com.itextpdf.text.PageSize;
+import com.itextpdf.text.Paragraph;
+import com.itextpdf.text.pdf.PdfWriter;
+
public class PDF2TextExample {
- private static final String FILENAME = "src/main/resources/pdf.pdf";
+ private static final String PDF = "src/main/resources/pdf.pdf";
+ private static final String TXT = "src/main/resources/txt.txt";
public static void main(String[] args) {
try {
- generateTxtFromPDF(FILENAME);
- } catch (IOException e) {
+ generateTxtFromPDF(PDF);
+ generatePDFFromTxt(TXT);
+ } catch (IOException | DocumentException e) {
e.printStackTrace();
}
}
@@ -45,4 +58,27 @@ public class PDF2TextExample {
pw.close();
}
+ private static void generatePDFFromTxt(String filename) throws IOException, DocumentException {
+ Document pdfDoc = new Document(PageSize.A4);
+ PdfWriter.getInstance(pdfDoc, new FileOutputStream("src/output/txt.pdf"))
+ .setPdfVersion(PdfWriter.PDF_VERSION_1_7);
+ pdfDoc.open();
+
+ Font myfont = new Font();
+ myfont.setStyle(Font.NORMAL);
+ myfont.setSize(11);
+ pdfDoc.add(new Paragraph("\n"));
+
+ BufferedReader br = new BufferedReader(new FileReader(filename));
+ String strLine;
+ while ((strLine = br.readLine()) != null) {
+ Paragraph para = new Paragraph(strLine + "\n", myfont);
+ para.setAlignment(Element.ALIGN_JUSTIFIED);
+ pdfDoc.add(para);
+ }
+
+ pdfDoc.close();
+ br.close();
+ }
+
}
diff --git a/pdf/src/main/resources/html.html b/pdf/src/main/resources/html.html
new file mode 100644
index 0000000000..d3072c056c
--- /dev/null
+++ b/pdf/src/main/resources/html.html
@@ -0,0 +1,53 @@
+
+
+
+
+A very simple webpage
+
+
+
+A very simple webpage. This is an "h1" level header.
+
+This is a level h2 header.
+
+This is a level h6 header. Pretty small!
+
+This is a standard paragraph.
+
+Now I've aligned it in the center of the screen.
+
+Now aligned to the right
+
+Bold text
+
+Strongly emphasized text Can you tell the difference vs. bold?
+
+Italics
+
+Emphasized text Just like Italics!
+
+How about a nice ordered list!
+
+ - This little piggy went to market
+ - This little piggy went to SB228 class
+ - This little piggy went to an expensive restaurant in Downtown Palo Alto
+ - This little piggy ate too much at Indian Buffet.
+ - This little piggy got lost
+
+
+Unordered list
+
+ - First element
+ - Second element
+ - Third element
+
+
+
+And finally, how about some
Links?
+
+Remember, you can view the HTMl code from this or any other page by using the "View Page Source" command of your browser.
+
+
+
+
+
diff --git a/pdf/src/main/resources/txt.txt b/pdf/src/main/resources/txt.txt
new file mode 100644
index 0000000000..de0c36ae75
--- /dev/null
+++ b/pdf/src/main/resources/txt.txt
@@ -0,0 +1,3 @@
+Test
+Text
+ Test TEST
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 9dfb0fdaaf..1dde581d13 100644
--- a/pom.xml
+++ b/pom.xml
@@ -47,16 +47,18 @@
immutables
jackson
+ jackson-annotations
java-cassandra
+ javax-servlets
javaxval
jee7
jjwt
jpa-storedprocedure
- jsf
+ jsf
json-path
json
junit5
-
+
log4j
log-mdc
lombok
@@ -72,19 +74,19 @@
querydsl
- redis
+ redis
rest-assured
rest-testing
resteasy
selenium-junit-testng
- spring-akka
+ spring-akka
spring-all
spring-apache-camel
spring-autowire
spring-batch
spring-boot
- spring-cloud-data-flow
+ spring-cloud-data-flow
spring-cloud
spring-core
spring-cucumber
@@ -109,6 +111,7 @@
spring-katharsis
spring-mockito
spring-mvc-java
+ spring-mvc-forms
spring-mvc-no-xml
spring-mvc-tiles
spring-mvc-velocity
@@ -132,7 +135,7 @@
spring-security-rest-custom
spring-security-rest-digest-auth
spring-security-rest-full
- spring-security-rest
+ spring-security-rest
spring-security-x509
spring-session
spring-spel
diff --git a/selenium-junit-testng/src/main/java/com/baeldung/selenium/SeleniumExample.java b/selenium-junit-testng/src/main/java/com/baeldung/selenium/SeleniumExample.java
index dd309cec79..b97f66e9dd 100644
--- a/selenium-junit-testng/src/main/java/com/baeldung/selenium/SeleniumExample.java
+++ b/selenium-junit-testng/src/main/java/com/baeldung/selenium/SeleniumExample.java
@@ -1,14 +1,13 @@
package main.java.com.baeldung.selenium;
-import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.concurrent.TimeUnit;
-
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
public class SeleniumExample {
private WebDriver webDriver;
@@ -38,12 +37,12 @@ public class SeleniumExample {
private void closeOverlay() {
List webElementList = webDriver.findElements(By.tagName("a"));
- try {
- if (webElementList != null && !webElementList.isEmpty()) {
- webElementList.stream().filter(webElement -> "Close".equalsIgnoreCase(webElement.getAttribute("title"))).findAny().orElseThrow(NoSuchElementException::new).click();
- }
- } catch (NoSuchElementException exception) {
- exception.printStackTrace();
+ if (webElementList != null) {
+ webElementList.stream()
+ .filter(webElement -> "Close".equalsIgnoreCase(webElement.getAttribute("title")))
+ .filter(WebElement::isDisplayed)
+ .findAny()
+ .ifPresent(WebElement::click);
}
}
diff --git a/spring-apache-camel/pom.xml b/spring-apache-camel/pom.xml
index fbea9b779d..6cd4f136e0 100644
--- a/spring-apache-camel/pom.xml
+++ b/spring-apache-camel/pom.xml
@@ -11,25 +11,26 @@
2.16.1
4.2.4.RELEASE
+ 2.19.1
1.7
- 4.1
+ 4.12
-
+
junit
junit
${junit.version}
test
-
+
org.apache.camel
camel-core
${env.camel.version}
-
+
org.apache.camel
camel-spring
@@ -49,7 +50,7 @@
-
+
@@ -62,6 +63,22 @@
${java.version}
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ ${maven-surefire-plugin.version}
+
+
+ **/*IntegrationTest.java
+
+
+
+
+
+
+
+
diff --git a/spring-apache-camel/src/test/java/org/apache/camel/file/processor/FileProcessorIntegrationTest.java b/spring-apache-camel/src/test/java/org/apache/camel/file/processor/FileProcessorIntegrationTest.java
new file mode 100644
index 0000000000..e73ad1e4a4
--- /dev/null
+++ b/spring-apache-camel/src/test/java/org/apache/camel/file/processor/FileProcessorIntegrationTest.java
@@ -0,0 +1,68 @@
+package org.apache.camel.file.processor;
+
+import java.io.File;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import com.baeldung.camel.file.FileProcessor;
+
+
+public class FileProcessorIntegrationTest {
+
+ private static final long DURATION_MILIS = 10000;
+ private static final String SOURCE_FOLDER = "src/test/source-folder";
+ private static final String DESTINATION_FOLDER = "src/test/destination-folder";
+
+ @Before
+ public void setUp() throws Exception {
+ File sourceFolder = new File(SOURCE_FOLDER);
+ File destinationFolder = new File(DESTINATION_FOLDER);
+
+ cleanFolder(sourceFolder);
+ cleanFolder(destinationFolder);
+
+ sourceFolder.mkdirs();
+ File file1 = new File(SOURCE_FOLDER + "/File1.txt");
+ File file2 = new File(SOURCE_FOLDER + "/File2.txt");
+ file1.createNewFile();
+ file2.createNewFile();
+ }
+
+ private void cleanFolder(File folder) {
+ File[] files = folder.listFiles();
+ if (files != null) {
+ for (File file : files) {
+ if (file.isFile()) {
+ file.delete();
+ }
+ }
+ }
+ }
+
+ @Test
+ public void moveFolderContentJavaDSLTest() throws Exception {
+ final CamelContext camelContext = new DefaultCamelContext();
+ camelContext.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("file://" + SOURCE_FOLDER + "?delete=true").process(new FileProcessor()).to("file://" + DESTINATION_FOLDER);
+ }
+ });
+ camelContext.start();
+ Thread.sleep(DURATION_MILIS);
+ camelContext.stop();
+ }
+
+ @Test
+ public void moveFolderContentSpringDSLTest() throws InterruptedException {
+ ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("camel-context-test.xml");
+ Thread.sleep(DURATION_MILIS);
+ applicationContext.close();
+
+ }
+}
\ No newline at end of file
diff --git a/spring-apache-camel/src/test/java/org/apache/camel/main/AppTest.java b/spring-apache-camel/src/test/java/org/apache/camel/main/AppIntegrationTest.java
similarity index 95%
rename from spring-apache-camel/src/test/java/org/apache/camel/main/AppTest.java
rename to spring-apache-camel/src/test/java/org/apache/camel/main/AppIntegrationTest.java
index 87b20369f3..fc7fa9653b 100644
--- a/spring-apache-camel/src/test/java/org/apache/camel/main/AppTest.java
+++ b/spring-apache-camel/src/test/java/org/apache/camel/main/AppIntegrationTest.java
@@ -15,7 +15,7 @@ import java.nio.channels.FileChannel;
import java.nio.file.Files;
import java.nio.file.Paths;
-public class AppTest extends TestCase {
+public class AppIntegrationTest extends TestCase {
private static final String FILE_NAME = "file.txt";
private static final String SAMPLE_INPUT_DIR = "src/test/data/sampleInputFile/";
diff --git a/spring-cloud/spring-cloud-bootstrap/config/src/main/java/com/baeldung/spring/cloud/bootstrap/config/ConfigApplication.java b/spring-cloud/spring-cloud-bootstrap/config/src/main/java/com/baeldung/spring/cloud/bootstrap/config/ConfigApplication.java
index 847c86f881..c51819dfe5 100644
--- a/spring-cloud/spring-cloud-bootstrap/config/src/main/java/com/baeldung/spring/cloud/bootstrap/config/ConfigApplication.java
+++ b/spring-cloud/spring-cloud-bootstrap/config/src/main/java/com/baeldung/spring/cloud/bootstrap/config/ConfigApplication.java
@@ -9,7 +9,7 @@ import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
@EnableConfigServer
@EnableEurekaClient
public class ConfigApplication {
- public static void main(String[] args) {
- SpringApplication.run(ConfigApplication.class, args);
- }
+ public static void main(String[] args) {
+ SpringApplication.run(ConfigApplication.class, args);
+ }
}
diff --git a/spring-cloud/spring-cloud-bootstrap/discovery/src/main/java/com/baeldung/spring/cloud/bootstrap/discovery/DiscoveryApplication.java b/spring-cloud/spring-cloud-bootstrap/discovery/src/main/java/com/baeldung/spring/cloud/bootstrap/discovery/DiscoveryApplication.java
index 32bcdc90b6..4ac445b083 100644
--- a/spring-cloud/spring-cloud-bootstrap/discovery/src/main/java/com/baeldung/spring/cloud/bootstrap/discovery/DiscoveryApplication.java
+++ b/spring-cloud/spring-cloud-bootstrap/discovery/src/main/java/com/baeldung/spring/cloud/bootstrap/discovery/DiscoveryApplication.java
@@ -7,7 +7,7 @@ import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@SpringBootApplication
@EnableEurekaServer
public class DiscoveryApplication {
- public static void main(String[] args) {
- SpringApplication.run(DiscoveryApplication.class, args);
- }
+ public static void main(String[] args) {
+ SpringApplication.run(DiscoveryApplication.class, args);
+ }
}
diff --git a/spring-cloud/spring-cloud-bootstrap/gateway/src/main/java/com/baeldung/spring/cloud/bootstrap/gateway/GatewayApplication.java b/spring-cloud/spring-cloud-bootstrap/gateway/src/main/java/com/baeldung/spring/cloud/bootstrap/gateway/GatewayApplication.java
index a3d2df5357..b5ae1e4e7b 100644
--- a/spring-cloud/spring-cloud-bootstrap/gateway/src/main/java/com/baeldung/spring/cloud/bootstrap/gateway/GatewayApplication.java
+++ b/spring-cloud/spring-cloud-bootstrap/gateway/src/main/java/com/baeldung/spring/cloud/bootstrap/gateway/GatewayApplication.java
@@ -18,23 +18,23 @@ import java.util.List;
@EnableZuulProxy
@EnableEurekaClient
public class GatewayApplication {
- public static void main(String[] args) {
- SpringApplication.run(GatewayApplication.class, args);
- }
+ public static void main(String[] args) {
+ SpringApplication.run(GatewayApplication.class, args);
+ }
- @Autowired(required = false)
- private List configurations = new ArrayList<>();
+ @Autowired(required = false)
+ private List configurations = new ArrayList<>();
- @Bean
- @LoadBalanced RestTemplate restTemplate(){
- return new RestTemplate();
- }
+ @Bean
+ @LoadBalanced
+ RestTemplate restTemplate() {
+ return new RestTemplate();
+ }
-
- @Bean
- public SpringClientFactory springClientFactory() {
- SpringClientFactory factory = new SpringClientFactory();
- factory.setConfigurations(this.configurations);
- return factory;
- }
+ @Bean
+ public SpringClientFactory springClientFactory() {
+ SpringClientFactory factory = new SpringClientFactory();
+ factory.setConfigurations(this.configurations);
+ return factory;
+ }
}
diff --git a/spring-cloud/spring-cloud-bootstrap/gateway/src/main/java/com/baeldung/spring/cloud/bootstrap/gateway/filter/SessionSavingZuulPreFilter.java b/spring-cloud/spring-cloud-bootstrap/gateway/src/main/java/com/baeldung/spring/cloud/bootstrap/gateway/filter/SessionSavingZuulPreFilter.java
index 9a2b5bab74..1c90ba2e12 100644
--- a/spring-cloud/spring-cloud-bootstrap/gateway/src/main/java/com/baeldung/spring/cloud/bootstrap/gateway/filter/SessionSavingZuulPreFilter.java
+++ b/spring-cloud/spring-cloud-bootstrap/gateway/src/main/java/com/baeldung/spring/cloud/bootstrap/gateway/filter/SessionSavingZuulPreFilter.java
@@ -14,34 +14,34 @@ import javax.servlet.http.HttpSession;
@Component
public class SessionSavingZuulPreFilter extends ZuulFilter {
- private Logger log = LoggerFactory.getLogger(this.getClass());
+ private Logger log = LoggerFactory.getLogger(this.getClass());
- @Autowired
- private SessionRepository repository;
+ @Autowired
+ private SessionRepository repository;
- @Override public boolean shouldFilter() {
- return true;
- }
+ @Override
+ public boolean shouldFilter() {
+ return true;
+ }
- @Override
- public Object run() {
- RequestContext context = RequestContext.getCurrentContext();
+ @Override
+ public Object run() {
+ RequestContext context = RequestContext.getCurrentContext();
+ HttpSession httpSession = context.getRequest().getSession();
+ Session session = repository.getSession(httpSession.getId());
- HttpSession httpSession = context.getRequest().getSession();
- Session session = repository.getSession(httpSession.getId());
+ context.addZuulRequestHeader("Cookie", "SESSION=" + httpSession.getId());
+ log.info("ZuulPreFilter session proxy: {}", session.getId());
+ return null;
+ }
- context.addZuulRequestHeader("Cookie", "SESSION=" + httpSession.getId());
+ @Override
+ public String filterType() {
+ return "pre";
+ }
- log.info("ZuulPreFilter session proxy: {}", session.getId());
-
- return null;
- }
-
- @Override public String filterType() {
- return "pre";
- }
-
- @Override public int filterOrder() {
- return 0;
- }
+ @Override
+ public int filterOrder() {
+ return 0;
+ }
}
diff --git a/spring-cloud/spring-cloud-bootstrap/resource/src/main/java/com/baeldung/spring/cloud/bootstrap/resource/ResourceApplication.java b/spring-cloud/spring-cloud-bootstrap/resource/src/main/java/com/baeldung/spring/cloud/bootstrap/resource/ResourceApplication.java
index e12d43f46b..accef18a14 100644
--- a/spring-cloud/spring-cloud-bootstrap/resource/src/main/java/com/baeldung/spring/cloud/bootstrap/resource/ResourceApplication.java
+++ b/spring-cloud/spring-cloud-bootstrap/resource/src/main/java/com/baeldung/spring/cloud/bootstrap/resource/ResourceApplication.java
@@ -11,31 +11,31 @@ import org.springframework.web.bind.annotation.RestController;
@EnableEurekaClient
@RestController
public class ResourceApplication {
- public static void main(String[] args) {
- SpringApplication.run(ResourceApplication.class, args);
- }
+ public static void main(String[] args) {
+ SpringApplication.run(ResourceApplication.class, args);
+ }
- @Value("${resource.returnString}")
- private String returnString;
+ @Value("${resource.returnString}")
+ private String returnString;
- @Value("${resource.user.returnString}")
- private String userReturnString;
+ @Value("${resource.user.returnString}")
+ private String userReturnString;
- @Value("${resource.admin.returnString}")
- private String adminReturnString;
+ @Value("${resource.admin.returnString}")
+ private String adminReturnString;
- @RequestMapping("/hello/cloud")
- public String getString() {
- return returnString;
- }
+ @RequestMapping("/hello/cloud")
+ public String getString() {
+ return returnString;
+ }
- @RequestMapping("/hello/user")
- public String getUserString() {
- return userReturnString;
- }
+ @RequestMapping("/hello/user")
+ public String getUserString() {
+ return userReturnString;
+ }
- @RequestMapping("/hello/admin")
- public String getAdminString() {
- return adminReturnString;
- }
+ @RequestMapping("/hello/admin")
+ public String getAdminString() {
+ return adminReturnString;
+ }
}
diff --git a/spring-core/.gitignore b/spring-core/.gitignore
index 6531dfc93f..08259abdaf 100644
--- a/spring-core/.gitignore
+++ b/spring-core/.gitignore
@@ -5,8 +5,8 @@ RemoteSystemsTempFiles/
bin/
.metadata/
docs/*.autosave
-docs/*.autosave
.recommenders/
build/
.gradle/
.DS_Store
+.idea/
\ No newline at end of file
diff --git a/spring-core/README.md b/spring-core/README.md
index 5554412c31..f05ba9384f 100644
--- a/spring-core/README.md
+++ b/spring-core/README.md
@@ -1,2 +1,5 @@
### Relevant Articles:
- [Wiring in Spring: @Autowired, @Resource and @Inject](http://www.baeldung.com/spring-annotations-resource-inject-autowire)
+- [Exploring the Spring BeanFactory API](http://www.baeldung.com/spring-beanfactory)
+- [How to use the Spring FactoryBean?](http://www.baeldung.com/spring-factorybean)
+
diff --git a/spring-core/pom.xml b/spring-core/pom.xml
index 9b94ba7b35..bf8c8f3ebc 100644
--- a/spring-core/pom.xml
+++ b/spring-core/pom.xml
@@ -4,22 +4,13 @@
4.0.0
com.baeldung
- dependency-injection
+ spring-core
0.0.1-SNAPSHOT
war
- dependency-injection
- Accompanying the demonstration of the use of the annotations related to injection mechanisms, namely
- Resource, Inject, and Autowired
-
+ spring-core
-
- junit
- junit
- 4.11
- test
-
org.mockito
mockito-all
@@ -50,6 +41,17 @@
javax.inject
1
+
+ junit
+ junit
+ 4.12
+ test
+
+
+ com.google.guava
+ guava
+ 20.0
+
diff --git a/spring-core/src/main/java/com/baeldung/beanfactory/Employee.java b/spring-core/src/main/java/com/baeldung/beanfactory/Employee.java
new file mode 100644
index 0000000000..bd7c7a5dc7
--- /dev/null
+++ b/spring-core/src/main/java/com/baeldung/beanfactory/Employee.java
@@ -0,0 +1,28 @@
+package com.baeldung.beanfactory;
+
+public class Employee {
+
+ private String name;
+ private int age;
+
+ public Employee(String name, int age) {
+ this.name = name;
+ this.age = age;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+}
diff --git a/spring-core/src/main/java/com/baeldung/constructordi/Config.java b/spring-core/src/main/java/com/baeldung/constructordi/Config.java
new file mode 100644
index 0000000000..07568018f3
--- /dev/null
+++ b/spring-core/src/main/java/com/baeldung/constructordi/Config.java
@@ -0,0 +1,23 @@
+package com.baeldung.constructordi;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+
+import com.baeldung.constructordi.domain.Engine;
+import com.baeldung.constructordi.domain.Transmission;
+
+@Configuration
+@ComponentScan("com.baeldung.constructordi")
+public class Config {
+
+ @Bean
+ public Engine engine() {
+ return new Engine("v8", 5);
+ }
+
+ @Bean
+ public Transmission transmission() {
+ return new Transmission("sliding");
+ }
+}
diff --git a/spring-core/src/main/java/com/baeldung/constructordi/SpringRunner.java b/spring-core/src/main/java/com/baeldung/constructordi/SpringRunner.java
new file mode 100644
index 0000000000..623739f036
--- /dev/null
+++ b/spring-core/src/main/java/com/baeldung/constructordi/SpringRunner.java
@@ -0,0 +1,31 @@
+package com.baeldung.constructordi;
+
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import com.baeldung.constructordi.domain.Car;
+
+public class SpringRunner {
+ public static void main(String[] args) {
+ Car toyota = getCarFromXml();
+
+ System.out.println(toyota);
+
+ toyota = getCarFromJavaConfig();
+
+ System.out.println(toyota);
+ }
+
+ private static Car getCarFromJavaConfig() {
+ ApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
+
+ return context.getBean(Car.class);
+ }
+
+ private static Car getCarFromXml() {
+ ApplicationContext context = new ClassPathXmlApplicationContext("baeldung.xml");
+
+ return context.getBean(Car.class);
+ }
+}
diff --git a/spring-core/src/main/java/com/baeldung/constructordi/domain/Car.java b/spring-core/src/main/java/com/baeldung/constructordi/domain/Car.java
new file mode 100644
index 0000000000..9f68ba5cd9
--- /dev/null
+++ b/spring-core/src/main/java/com/baeldung/constructordi/domain/Car.java
@@ -0,0 +1,21 @@
+package com.baeldung.constructordi.domain;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class Car {
+ private Engine engine;
+ private Transmission transmission;
+
+ @Autowired
+ public Car(Engine engine, Transmission transmission) {
+ this.engine = engine;
+ this.transmission = transmission;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("Engine: %s Transmission: %s", engine, transmission);
+ }
+}
diff --git a/spring-core/src/main/java/com/baeldung/constructordi/domain/Engine.java b/spring-core/src/main/java/com/baeldung/constructordi/domain/Engine.java
new file mode 100644
index 0000000000..f2987988eb
--- /dev/null
+++ b/spring-core/src/main/java/com/baeldung/constructordi/domain/Engine.java
@@ -0,0 +1,16 @@
+package com.baeldung.constructordi.domain;
+
+public class Engine {
+ private String type;
+ private int volume;
+
+ public Engine(String type, int volume) {
+ this.type = type;
+ this.volume = volume;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("%s %d", type, volume);
+ }
+}
diff --git a/spring-core/src/main/java/com/baeldung/constructordi/domain/Transmission.java b/spring-core/src/main/java/com/baeldung/constructordi/domain/Transmission.java
new file mode 100644
index 0000000000..85271e1f2a
--- /dev/null
+++ b/spring-core/src/main/java/com/baeldung/constructordi/domain/Transmission.java
@@ -0,0 +1,14 @@
+package com.baeldung.constructordi.domain;
+
+public class Transmission {
+ private String type;
+
+ public Transmission(String type) {
+ this.type = type;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("%s", type);
+ }
+}
diff --git a/spring-core/src/main/java/com/baeldung/factorybean/FactoryBeanAppConfig.java b/spring-core/src/main/java/com/baeldung/factorybean/FactoryBeanAppConfig.java
new file mode 100644
index 0000000000..e5e6d2ec05
--- /dev/null
+++ b/spring-core/src/main/java/com/baeldung/factorybean/FactoryBeanAppConfig.java
@@ -0,0 +1,16 @@
+package com.baeldung.factorybean;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class FactoryBeanAppConfig {
+
+ @Bean(name = "tool")
+ public ToolFactory toolFactory() {
+ ToolFactory factory = new ToolFactory();
+ factory.setFactoryId(7070);
+ factory.setToolId(2);
+ return factory;
+ }
+}
\ No newline at end of file
diff --git a/spring-core/src/main/java/com/baeldung/factorybean/NonSingleToolFactory.java b/spring-core/src/main/java/com/baeldung/factorybean/NonSingleToolFactory.java
new file mode 100644
index 0000000000..981df2206f
--- /dev/null
+++ b/spring-core/src/main/java/com/baeldung/factorybean/NonSingleToolFactory.java
@@ -0,0 +1,39 @@
+package com.baeldung.factorybean;
+
+import org.springframework.beans.factory.config.AbstractFactoryBean;
+
+public class NonSingleToolFactory extends AbstractFactoryBean {
+
+ private int factoryId;
+ private int toolId;
+
+ public NonSingleToolFactory() {
+ setSingleton(false);
+ }
+
+ @Override
+ public Class> getObjectType() {
+ return Tool.class;
+ }
+
+ @Override
+ protected Tool createInstance() throws Exception {
+ return new Tool(toolId);
+ }
+
+ public int getFactoryId() {
+ return factoryId;
+ }
+
+ public void setFactoryId(int factoryId) {
+ this.factoryId = factoryId;
+ }
+
+ public int getToolId() {
+ return toolId;
+ }
+
+ public void setToolId(int toolId) {
+ this.toolId = toolId;
+ }
+}
diff --git a/spring-core/src/main/java/com/baeldung/factorybean/SingleToolFactory.java b/spring-core/src/main/java/com/baeldung/factorybean/SingleToolFactory.java
new file mode 100644
index 0000000000..76b87bbbbf
--- /dev/null
+++ b/spring-core/src/main/java/com/baeldung/factorybean/SingleToolFactory.java
@@ -0,0 +1,36 @@
+package com.baeldung.factorybean;
+
+import org.springframework.beans.factory.config.AbstractFactoryBean;
+
+//no need to set singleton property because default value is true
+public class SingleToolFactory extends AbstractFactoryBean {
+
+ private int factoryId;
+ private int toolId;
+
+ @Override
+ public Class> getObjectType() {
+ return Tool.class;
+ }
+
+ @Override
+ protected Tool createInstance() throws Exception {
+ return new Tool(toolId);
+ }
+
+ public int getFactoryId() {
+ return factoryId;
+ }
+
+ public void setFactoryId(int factoryId) {
+ this.factoryId = factoryId;
+ }
+
+ public int getToolId() {
+ return toolId;
+ }
+
+ public void setToolId(int toolId) {
+ this.toolId = toolId;
+ }
+}
diff --git a/spring-core/src/main/java/com/baeldung/factorybean/Tool.java b/spring-core/src/main/java/com/baeldung/factorybean/Tool.java
new file mode 100644
index 0000000000..be56745b3d
--- /dev/null
+++ b/spring-core/src/main/java/com/baeldung/factorybean/Tool.java
@@ -0,0 +1,20 @@
+package com.baeldung.factorybean;
+
+public class Tool {
+ private int id;
+
+ public Tool() {
+ }
+
+ public Tool(int id) {
+ this.id = id;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+}
diff --git a/spring-core/src/main/java/com/baeldung/factorybean/ToolFactory.java b/spring-core/src/main/java/com/baeldung/factorybean/ToolFactory.java
new file mode 100644
index 0000000000..2a17574f8e
--- /dev/null
+++ b/spring-core/src/main/java/com/baeldung/factorybean/ToolFactory.java
@@ -0,0 +1,40 @@
+package com.baeldung.factorybean;
+
+import org.springframework.beans.factory.FactoryBean;
+
+public class ToolFactory implements FactoryBean {
+
+ private int factoryId;
+ private int toolId;
+
+ @Override
+ public Tool getObject() throws Exception {
+ return new Tool(toolId);
+ }
+
+ @Override
+ public Class> getObjectType() {
+ return Tool.class;
+ }
+
+ @Override
+ public boolean isSingleton() {
+ return false;
+ }
+
+ public int getFactoryId() {
+ return factoryId;
+ }
+
+ public void setFactoryId(int factoryId) {
+ this.factoryId = factoryId;
+ }
+
+ public int getToolId() {
+ return toolId;
+ }
+
+ public void setToolId(int toolId) {
+ this.toolId = toolId;
+ }
+}
diff --git a/spring-core/src/main/resources/baeldung.xml b/spring-core/src/main/resources/baeldung.xml
new file mode 100644
index 0000000000..d84492f1d4
--- /dev/null
+++ b/spring-core/src/main/resources/baeldung.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spring-core/src/main/resources/factorybean-abstract-spring-ctx.xml b/spring-core/src/main/resources/factorybean-abstract-spring-ctx.xml
new file mode 100644
index 0000000000..a82b884ee5
--- /dev/null
+++ b/spring-core/src/main/resources/factorybean-abstract-spring-ctx.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-core/src/main/resources/factorybean-spring-ctx.xml b/spring-core/src/main/resources/factorybean-spring-ctx.xml
new file mode 100644
index 0000000000..3231fda676
--- /dev/null
+++ b/spring-core/src/main/resources/factorybean-spring-ctx.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-core/src/test/java/com/baeldung/beanfactory/BeanFactoryWithClassPathResourceTest.java b/spring-core/src/test/java/com/baeldung/beanfactory/BeanFactoryWithClassPathResourceTest.java
new file mode 100644
index 0000000000..80123a1bee
--- /dev/null
+++ b/spring-core/src/test/java/com/baeldung/beanfactory/BeanFactoryWithClassPathResourceTest.java
@@ -0,0 +1,25 @@
+package com.baeldung.beanfactory;
+
+import org.junit.Test;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.xml.XmlBeanFactory;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class BeanFactoryWithClassPathResourceTest {
+
+ @Test
+ public void createBeanFactoryAndCheckEmployeeBean() {
+ Resource res = new ClassPathResource("beanfactory-example.xml");
+ BeanFactory factory = new XmlBeanFactory(res);
+ Employee emp = (Employee) factory.getBean("employee");
+
+ assertTrue(factory.isSingleton("employee"));
+ assertTrue(factory.getBean("employee") instanceof Employee);
+ assertTrue(factory.isTypeMatch("employee", Employee.class));
+ assertTrue(factory.getAliases("employee").length > 0);
+ }
+}
diff --git a/spring-core/src/test/java/com/baeldung/factorybean/AbstractFactoryBeanTest.java b/spring-core/src/test/java/com/baeldung/factorybean/AbstractFactoryBeanTest.java
new file mode 100644
index 0000000000..aa6d7c2cd2
--- /dev/null
+++ b/spring-core/src/test/java/com/baeldung/factorybean/AbstractFactoryBeanTest.java
@@ -0,0 +1,39 @@
+package com.baeldung.factorybean;
+
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+import javax.annotation.Resource;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = { "classpath:factorybean-abstract-spring-ctx.xml" })
+public class AbstractFactoryBeanTest {
+
+ @Resource(name = "singleTool")
+ private Tool tool1;
+ @Resource(name = "singleTool")
+ private Tool tool2;
+ @Resource(name = "nonSingleTool")
+ private Tool tool3;
+ @Resource(name = "nonSingleTool")
+ private Tool tool4;
+
+ @Test
+ public void testSingleToolFactory() {
+ assertThat(tool1.getId(), equalTo(1));
+ assertTrue(tool1 == tool2);
+ }
+
+ @Test
+ public void testNonSingleToolFactory() {
+ assertThat(tool3.getId(), equalTo(2));
+ assertThat(tool4.getId(), equalTo(2));
+ assertTrue(tool3 != tool4);
+ }
+}
diff --git a/spring-core/src/test/java/com/baeldung/factorybean/FactoryBeanJavaConfigTest.java b/spring-core/src/test/java/com/baeldung/factorybean/FactoryBeanJavaConfigTest.java
new file mode 100644
index 0000000000..c725f786dc
--- /dev/null
+++ b/spring-core/src/test/java/com/baeldung/factorybean/FactoryBeanJavaConfigTest.java
@@ -0,0 +1,29 @@
+package com.baeldung.factorybean;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import javax.annotation.Resource;
+
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = FactoryBeanAppConfig.class)
+public class FactoryBeanJavaConfigTest {
+
+ @Autowired
+ private Tool tool;
+
+ @Resource(name = "&tool")
+ private ToolFactory toolFactory;
+
+ @Test
+ public void testConstructWorkerByJava() {
+ assertThat(tool.getId(), equalTo(2));
+ assertThat(toolFactory.getFactoryId(), equalTo(7070));
+ }
+}
\ No newline at end of file
diff --git a/spring-core/src/test/java/com/baeldung/factorybean/FactoryBeanXmlConfigTest.java b/spring-core/src/test/java/com/baeldung/factorybean/FactoryBeanXmlConfigTest.java
new file mode 100644
index 0000000000..443515f872
--- /dev/null
+++ b/spring-core/src/test/java/com/baeldung/factorybean/FactoryBeanXmlConfigTest.java
@@ -0,0 +1,28 @@
+package com.baeldung.factorybean;
+
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
+
+import javax.annotation.Resource;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = { "classpath:factorybean-spring-ctx.xml" })
+public class FactoryBeanXmlConfigTest {
+
+ @Autowired
+ private Tool tool;
+ @Resource(name = "&tool")
+ private ToolFactory toolFactory;
+
+ @Test
+ public void testConstructWorkerByXml() {
+ assertThat(tool.getId(), equalTo(1));
+ assertThat(toolFactory.getFactoryId(), equalTo(9090));
+ }
+}
\ No newline at end of file
diff --git a/spring-core/src/test/resources/beanfactory-example.xml b/spring-core/src/test/resources/beanfactory-example.xml
new file mode 100644
index 0000000000..7b3d4f29ed
--- /dev/null
+++ b/spring-core/src/test/resources/beanfactory-example.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-data-solr/pom.xml b/spring-data-solr/pom.xml
index bd48a53d06..ec6eb7bf46 100644
--- a/spring-data-solr/pom.xml
+++ b/spring-data-solr/pom.xml
@@ -1,21 +1,21 @@
-
+
4.0.0
com.baeldung
spring-data-solr
0.0.1-SNAPSHOT
jar
spring-data-solr
-
-
+
+
UTF-8
4.2.5.RELEASE
2.19.1
2.0.4.RELEASE
-
+
org.springframework
@@ -50,20 +50,58 @@
test
-
+
+
+ maven-compiler-plugin
+
org.apache.maven.plugins
maven-surefire-plugin
${maven-surefire-plugin.version}
-
- **/*IntegrationTest.java
-
+
+ **/*IntegrationTest.java
+ **/*LiveTest.java
+
-
-
+
+
+
+ integration
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ integration-test
+
+ test
+
+
+
+ **/*LiveTest.java
+
+
+ **/*IntegrationTest.java
+
+
+
+
+
+
+ json
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-data-solr/src/main/java/com/baeldung/spring/data/solr/model/Product.java b/spring-data-solr/src/main/java/com/baeldung/spring/data/solr/model/Product.java
index 7cd0890718..5286f53309 100644
--- a/spring-data-solr/src/main/java/com/baeldung/spring/data/solr/model/Product.java
+++ b/spring-data-solr/src/main/java/com/baeldung/spring/data/solr/model/Product.java
@@ -6,50 +6,28 @@ import org.springframework.data.solr.core.mapping.SolrDocument;
@SolrDocument(solrCoreName = "product")
public class Product {
-
+
@Id
@Indexed(name = "id", type = "string")
private String id;
-
+
@Indexed(name = "name", type = "string")
private String name;
-
- @Indexed(name = "category", type = "string")
- private String category;
-
- @Indexed(name = "description", type = "string")
- private String description;
-
+
public String getId() {
return id;
}
-
+
public void setId(String id) {
this.id = id;
}
-
+
public String getName() {
return name;
}
-
+
public void setName(String name) {
this.name = name;
}
-
- public String getCategory() {
- return category;
- }
-
- public void setCategory(String category) {
- this.category = category;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
+
}
diff --git a/spring-data-solr/src/main/java/com/baeldung/spring/data/solr/repository/ProductRepository.java b/spring-data-solr/src/main/java/com/baeldung/spring/data/solr/repository/ProductRepository.java
index 01ec1fb909..5649cd7888 100644
--- a/spring-data-solr/src/main/java/com/baeldung/spring/data/solr/repository/ProductRepository.java
+++ b/spring-data-solr/src/main/java/com/baeldung/spring/data/solr/repository/ProductRepository.java
@@ -13,7 +13,7 @@ public interface ProductRepository extends SolrCrudRepository {
public List findByName(String name);
- @Query("name:*?0* OR category:*?0* OR description:*?0*")
+ @Query("id:*?0* OR name:*?0*")
public Page findByCustomQuery(String searchTerm, Pageable pageable);
@Query(name = "Product.findByNamedQuery")
diff --git a/spring-data-solr/src/main/resources/solr-named-queries.properties b/spring-data-solr/src/main/resources/solr-named-queries.properties
index cec59cbebd..c00b5bace9 100644
--- a/spring-data-solr/src/main/resources/solr-named-queries.properties
+++ b/spring-data-solr/src/main/resources/solr-named-queries.properties
@@ -1 +1 @@
-Product.findByNamedQuery=name:*?0* OR category:*?0* OR description:*?0*
\ No newline at end of file
+Product.findByNamedQuery=id:*?0* OR name:*?0*
\ No newline at end of file
diff --git a/spring-data-solr/src/test/java/com/baeldung/spring/data/solr/repo/ProductRepositoryIntegrationTest.java b/spring-data-solr/src/test/java/com/baeldung/spring/data/solr/repo/ProductRepositoryIntegrationTest.java
index 74d94ef91c..a3765a74ec 100644
--- a/spring-data-solr/src/test/java/com/baeldung/spring/data/solr/repo/ProductRepositoryIntegrationTest.java
+++ b/spring-data-solr/src/test/java/com/baeldung/spring/data/solr/repo/ProductRepositoryIntegrationTest.java
@@ -21,124 +21,105 @@ import com.baeldung.spring.data.solr.repository.ProductRepository;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = SolrConfig.class)
public class ProductRepositoryIntegrationTest {
-
+
@Autowired
private ProductRepository productRepository;
-
+
@Before
public void clearSolrData() {
productRepository.deleteAll();
}
-
+
@Test
public void whenSavingProduct_thenAvailableOnRetrieval() throws Exception {
final Product product = new Product();
product.setId("P000089998");
product.setName("Desk");
- product.setCategory("Furniture");
- product.setDescription("New Desk");
productRepository.save(product);
final Product retrievedProduct = productRepository.findOne(product.getId());
assertEquals(product.getId(), retrievedProduct.getId());
}
-
+
@Test
public void whenUpdatingProduct_thenChangeAvailableOnRetrieval() throws Exception {
final Product product = new Product();
product.setId("P0001");
product.setName("T-Shirt");
- product.setCategory("Kitchen");
- product.setDescription("New T-Shirt");
+
productRepository.save(product);
-
- product.setCategory("Clothes");
+
+ product.setName("Shirt");
productRepository.save(product);
-
+
final Product retrievedProduct = productRepository.findOne(product.getId());
- assertEquals(product.getCategory(), retrievedProduct.getCategory());
+ assertEquals(product.getName(), retrievedProduct.getName());
}
-
+
@Test
public void whenDeletingProduct_thenNotAvailableOnRetrieval() throws Exception {
final Product product = new Product();
product.setId("P0001");
product.setName("Desk");
- product.setCategory("Furniture");
- product.setDescription("New Desk");
productRepository.save(product);
-
+
productRepository.delete(product);
-
+
Product retrievedProduct = productRepository.findOne(product.getId());
assertNull(retrievedProduct);
-
+
}
-
+
@Test
public void whenFindByName_thenAvailableOnRetrieval() throws Exception {
Product phone = new Product();
phone.setId("P0001");
phone.setName("Phone");
- phone.setCategory("Electronics");
- phone.setDescription("New Phone");
productRepository.save(phone);
-
+
List retrievedProducts = productRepository.findByName("Phone");
assertEquals(phone.getId(), retrievedProducts.get(0).getId());
}
-
+
@Test
public void whenSearchingProductsByQuery_thenAllMatchingProductsShouldAvialble() throws Exception {
final Product phone = new Product();
phone.setId("P0001");
phone.setName("Smart Phone");
- phone.setCategory("Electronics");
- phone.setDescription("New Item");
productRepository.save(phone);
-
+
final Product phoneCover = new Product();
phoneCover.setId("P0002");
- phoneCover.setName("Cover");
- phoneCover.setCategory("Phone");
- phoneCover.setDescription("New Product");
+ phoneCover.setName("Phone Cover");
productRepository.save(phoneCover);
-
+
final Product wirelessCharger = new Product();
wirelessCharger.setId("P0003");
- wirelessCharger.setName("Charging Cable");
- wirelessCharger.setCategory("Cable");
- wirelessCharger.setDescription("Wireless Charger for Phone");
+ wirelessCharger.setName("Phone Charging Cable");
productRepository.save(wirelessCharger);
-
+
Page result = productRepository.findByCustomQuery("Phone", new PageRequest(0, 10));
assertEquals(3, result.getNumberOfElements());
}
-
+
@Test
public void whenSearchingProductsByNamedQuery_thenAllMatchingProductsShouldAvialble() throws Exception {
final Product phone = new Product();
phone.setId("P0001");
phone.setName("Smart Phone");
- phone.setCategory("Electronics");
- phone.setDescription("New Item");
productRepository.save(phone);
-
+
final Product phoneCover = new Product();
phoneCover.setId("P0002");
- phoneCover.setName("Cover");
- phoneCover.setCategory("Phone");
- phoneCover.setDescription("New Product");
+ phoneCover.setName("Phone Cover");
productRepository.save(phoneCover);
-
+
final Product wirelessCharger = new Product();
wirelessCharger.setId("P0003");
- wirelessCharger.setName("Charging Cable");
- wirelessCharger.setCategory("Cable");
- wirelessCharger.setDescription("Wireless Charger for Phone");
+ wirelessCharger.setName("Phone Charging Cable");
productRepository.save(wirelessCharger);
-
+
Page result = productRepository.findByNamedQuery("one", new PageRequest(0, 10));
assertEquals(3, result.getNumberOfElements());
}
-
+
}
diff --git a/spring-integration/src/main/java/com/baeldung/samples/FileCopyConfig.java b/spring-integration/src/main/java/com/baeldung/samples/FileCopyConfig.java
new file mode 100644
index 0000000000..aec2ae8858
--- /dev/null
+++ b/spring-integration/src/main/java/com/baeldung/samples/FileCopyConfig.java
@@ -0,0 +1,73 @@
+package com.baeldung.samples;
+
+import java.io.File;
+import java.util.Scanner;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.integration.annotation.InboundChannelAdapter;
+import org.springframework.integration.annotation.Poller;
+import org.springframework.integration.annotation.ServiceActivator;
+import org.springframework.integration.channel.DirectChannel;
+import org.springframework.integration.config.EnableIntegration;
+import org.springframework.integration.core.MessageSource;
+import org.springframework.integration.file.FileReadingMessageSource;
+import org.springframework.integration.file.FileWritingMessageHandler;
+import org.springframework.integration.file.filters.SimplePatternFileListFilter;
+import org.springframework.integration.file.support.FileExistsMode;
+import org.springframework.messaging.MessageChannel;
+import org.springframework.messaging.MessageHandler;
+
+@Configuration
+@EnableIntegration
+public class FileCopyConfig {
+
+ public final String INPUT_DIR = "source";
+ public final String OUTPUT_DIR = "target";
+ public final String FILE_PATTERN = "*.jpg";
+
+ @Bean
+ public MessageChannel fileChannel() {
+ return new DirectChannel();
+ }
+
+ @Bean
+ @InboundChannelAdapter(value = "fileChannel", poller = @Poller(fixedDelay = "10000"))
+ public MessageSource fileReadingMessageSource() {
+ FileReadingMessageSource sourceReader = new FileReadingMessageSource();
+ sourceReader.setDirectory(new File(INPUT_DIR));
+ sourceReader.setFilter(new SimplePatternFileListFilter(FILE_PATTERN));
+ return sourceReader;
+ }
+
+ @Bean
+ @ServiceActivator(inputChannel = "fileChannel")
+ public MessageHandler fileWritingMessageHandler() {
+ FileWritingMessageHandler handler = new FileWritingMessageHandler(new File(OUTPUT_DIR));
+ handler.setFileExistsMode(FileExistsMode.REPLACE);
+ handler.setExpectReply(false);
+ return handler;
+ }
+
+ public static void main(final String... args) {
+ final AbstractApplicationContext context = new AnnotationConfigApplicationContext(FileCopyConfig.class);
+ context.registerShutdownHook();
+ final Scanner scanner = new Scanner(System.in);
+ System.out.print("Please enter a string and press : ");
+ while (true) {
+ final String input = scanner.nextLine();
+ if ("q".equals(input.trim())) {
+ context.close();
+ scanner.close();
+ break;
+ }
+ }
+ System.exit(0);
+ }
+
+}
+
+
+
diff --git a/spring-integration/src/main/resources/log4j.xml b/spring-integration/src/main/resources/log4j.xml
new file mode 100644
index 0000000000..cfa93a8037
--- /dev/null
+++ b/spring-integration/src/main/resources/log4j.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spring-integration/src/test/java/com/baeldung/samples/FileCopyTest.java b/spring-integration/src/test/java/com/baeldung/samples/FileCopyTest.java
index 96e5a98f41..567d181972 100644
--- a/spring-integration/src/test/java/com/baeldung/samples/FileCopyTest.java
+++ b/spring-integration/src/test/java/com/baeldung/samples/FileCopyTest.java
@@ -17,11 +17,10 @@ package com.baeldung.samples;
import org.apache.log4j.Logger;
import org.junit.Test;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
-import java.util.Scanner;
-
/**
* Starts the Spring Context and will initialize the Spring Integration routes.
@@ -35,15 +34,10 @@ public final class FileCopyTest {
private static final Logger LOGGER = Logger.getLogger(FileCopyTest.class);
@Test
- public void test() throws InterruptedException {
-
-
- final AbstractApplicationContext context =
- new ClassPathXmlApplicationContext("classpath:META-INF/spring/integration/spring-integration-file-copy-context.xml");
-
+ public void whenFileCopyConfiguration_thanFileCopiedSuccessfully() throws InterruptedException {
+ final AbstractApplicationContext context = new AnnotationConfigApplicationContext(FileCopyConfig.class.getCanonicalName());
+ context.registerShutdownHook();
Thread.sleep(5000);
-
-
}
@Test
diff --git a/spring-jpa/src/main/java/org/baeldung/config/PersistenceJPAConfigL2Cache.java b/spring-jpa/src/main/java/org/baeldung/config/PersistenceJPAConfigL2Cache.java
index 3ca0dbf5e4..8768bac58c 100644
--- a/spring-jpa/src/main/java/org/baeldung/config/PersistenceJPAConfigL2Cache.java
+++ b/spring-jpa/src/main/java/org/baeldung/config/PersistenceJPAConfigL2Cache.java
@@ -40,7 +40,7 @@ public class PersistenceJPAConfigL2Cache {
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(dataSource());
- em.setPackagesToScan(new String[] { "org.baeldung.persistence.model" });
+ em.setPackagesToScan(getPackagesToScan());
final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
em.setJpaVendorAdapter(vendorAdapter);
@@ -49,6 +49,10 @@ public class PersistenceJPAConfigL2Cache {
return em;
}
+ protected String[] getPackagesToScan() {
+ return new String[] { "org.baeldung.persistence.model" };
+ }
+
@Bean
public DataSource dataSource() {
final DriverManagerDataSource dataSource = new DriverManagerDataSource();
@@ -78,6 +82,7 @@ public class PersistenceJPAConfigL2Cache {
hibernateProperties.setProperty("hibernate.cache.use_second_level_cache", env.getProperty("hibernate.cache.use_second_level_cache"));
hibernateProperties.setProperty("hibernate.cache.use_query_cache", env.getProperty("hibernate.cache.use_query_cache"));
hibernateProperties.setProperty("hibernate.cache.region.factory_class", env.getProperty("hibernate.cache.region.factory_class"));
+ hibernateProperties.setProperty("hibernate.show_sql", env.getProperty("hibernate.show_sql"));
return hibernateProperties;
}
diff --git a/spring-jpa/src/main/resources/persistence-h2.properties b/spring-jpa/src/main/resources/persistence-h2.properties
index d195af5ec9..2c3e18b58d 100644
--- a/spring-jpa/src/main/resources/persistence-h2.properties
+++ b/spring-jpa/src/main/resources/persistence-h2.properties
@@ -6,7 +6,7 @@ jdbc.user=sa
# hibernate.X
hibernate.dialect=org.hibernate.dialect.H2Dialect
-hibernate.show_sql=false
+hibernate.show_sql=true
hibernate.hbm2ddl.auto=create-drop
hibernate.cache.use_second_level_cache=true
hibernate.cache.use_query_cache=true
diff --git a/spring-jpa/src/test/java/org/baeldung/persistence/deletion/config/PersistenceJPAConfigDeletion.java b/spring-jpa/src/test/java/org/baeldung/persistence/deletion/config/PersistenceJPAConfigDeletion.java
new file mode 100644
index 0000000000..37388d1c51
--- /dev/null
+++ b/spring-jpa/src/test/java/org/baeldung/persistence/deletion/config/PersistenceJPAConfigDeletion.java
@@ -0,0 +1,17 @@
+package org.baeldung.persistence.deletion.config;
+
+import org.baeldung.config.PersistenceJPAConfigL2Cache;
+
+import java.util.Properties;
+
+public class PersistenceJPAConfigDeletion extends PersistenceJPAConfigL2Cache {
+
+ public PersistenceJPAConfigDeletion() {
+ super();
+ }
+
+ @Override
+ protected String[] getPackagesToScan() {
+ return new String[] { "org.baeldung.persistence.deletion.model" };
+ }
+}
\ No newline at end of file
diff --git a/spring-jpa/src/test/java/org/baeldung/persistence/deletion/model/Bar.java b/spring-jpa/src/test/java/org/baeldung/persistence/deletion/model/Bar.java
new file mode 100644
index 0000000000..26c4846fd2
--- /dev/null
+++ b/spring-jpa/src/test/java/org/baeldung/persistence/deletion/model/Bar.java
@@ -0,0 +1,60 @@
+package org.baeldung.persistence.deletion.model;
+
+import javax.persistence.*;
+import java.util.ArrayList;
+import java.util.List;
+
+@Entity
+@Table(name = "BAR")
+public class Bar {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private long id;
+
+ @Column(nullable = false)
+ private String name;
+
+ @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
+ List bazList = new ArrayList<>();
+
+ public Bar() {
+ super();
+ }
+
+ public Bar(final String name) {
+ super();
+ this.name = name;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(final long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ public List getBazList() {
+ return bazList;
+ }
+
+ public void setBazList(final List bazList) {
+ this.bazList = bazList;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder();
+ builder.append("Bar [name=").append(name).append("]");
+ return builder.toString();
+ }
+}
diff --git a/spring-jpa/src/test/java/org/baeldung/persistence/deletion/model/Baz.java b/spring-jpa/src/test/java/org/baeldung/persistence/deletion/model/Baz.java
new file mode 100644
index 0000000000..2dad3e6654
--- /dev/null
+++ b/spring-jpa/src/test/java/org/baeldung/persistence/deletion/model/Baz.java
@@ -0,0 +1,48 @@
+package org.baeldung.persistence.deletion.model;
+
+import javax.persistence.*;
+import java.util.List;
+
+@Entity
+@Table(name = "BAZ")
+public class Baz {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private long id;
+
+ @Column(nullable = false)
+ private String name;
+
+ public Baz() {
+ super();
+ }
+
+ public Baz(final String name) {
+ super();
+ this.name = name;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(final long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder();
+ builder.append("Bar [name=").append(name).append("]");
+ return builder.toString();
+ }
+}
diff --git a/spring-jpa/src/test/java/org/baeldung/persistence/deletion/model/Foo.java b/spring-jpa/src/test/java/org/baeldung/persistence/deletion/model/Foo.java
new file mode 100644
index 0000000000..00fc34c166
--- /dev/null
+++ b/spring-jpa/src/test/java/org/baeldung/persistence/deletion/model/Foo.java
@@ -0,0 +1,63 @@
+package org.baeldung.persistence.deletion.model;
+
+import org.hibernate.annotations.Where;
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "FOO")
+@Where(clause = "DELETED = 0")
+public class Foo {
+
+ public Foo() {
+ super();
+ }
+
+ public Foo(final String name) {
+ super();
+ this.name = name;
+ }
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(name = "ID")
+ private long id;
+
+ @Column(name = "NAME")
+ private String name;
+
+ @Column(name = "DELETED")
+ private Integer deleted = 0;
+
+ @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
+ @JoinColumn(name = "BAR_ID")
+ private Bar bar;
+
+ public Bar getBar() {
+ return bar;
+ }
+
+ public void setBar(final Bar bar) {
+ this.bar = bar;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(final int id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ public void setDeleted() {
+ this.deleted = 1;
+ }
+}
diff --git a/spring-jpa/src/test/java/org/baeldung/persistence/service/DeletionIntegrationTest.java b/spring-jpa/src/test/java/org/baeldung/persistence/service/DeletionIntegrationTest.java
new file mode 100644
index 0000000000..9e5c5fa07a
--- /dev/null
+++ b/spring-jpa/src/test/java/org/baeldung/persistence/service/DeletionIntegrationTest.java
@@ -0,0 +1,159 @@
+package org.baeldung.persistence.service;
+
+import org.baeldung.persistence.deletion.config.PersistenceJPAConfigDeletion;
+import org.baeldung.persistence.deletion.model.Bar;
+import org.baeldung.persistence.deletion.model.Baz;
+import org.baeldung.persistence.deletion.model.Foo;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.support.AnnotationConfigContextLoader;
+import org.springframework.transaction.PlatformTransactionManager;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = { PersistenceJPAConfigDeletion.class }, loader = AnnotationConfigContextLoader.class)
+public class DeletionIntegrationTest {
+
+ @PersistenceContext
+ private EntityManager entityManager;
+ @Autowired
+ private PlatformTransactionManager platformTransactionManager;
+
+ @Before
+ public final void before() {
+ entityManager.getEntityManagerFactory().getCache().evictAll();
+ }
+
+ @Test
+ @Transactional
+ public final void givenEntityIsRemoved_thenItIsNotInDB() {
+ Foo foo = new Foo("foo");
+ entityManager.persist(foo);
+ flushAndClear();
+
+ foo = entityManager.find(Foo.class, foo.getId());
+ assertThat(foo, notNullValue());
+
+ entityManager.remove(foo);
+ flushAndClear();
+
+ assertThat(entityManager.find(Foo.class, foo.getId()), nullValue());
+ }
+
+ @Test
+ @Transactional
+ public final void givenEntityIsRemovedAndReferencedByAnotherEntity_thenItIsNotRemoved() {
+ Bar bar = new Bar("bar");
+ Foo foo = new Foo("foo");
+ foo.setBar(bar);
+ entityManager.persist(foo);
+ flushAndClear();
+
+ foo = entityManager.find(Foo.class, foo.getId());
+ bar = entityManager.find(Bar.class, bar.getId());
+ entityManager.remove(bar);
+ flushAndClear();
+
+ bar = entityManager.find(Bar.class, bar.getId());
+ assertThat(bar, notNullValue());
+
+ foo = entityManager.find(Foo.class, foo.getId());
+ foo.setBar(null);
+ entityManager.remove(bar);
+ flushAndClear();
+
+ assertThat(entityManager.find(Bar.class, bar.getId()), nullValue());
+ }
+
+ @Test
+ @Transactional
+ public final void givenEntityIsRemoved_thenRemovalIsCascaded() {
+ Bar bar = new Bar("bar");
+ Foo foo = new Foo("foo");
+ foo.setBar(bar);
+ entityManager.persist(foo);
+ flushAndClear();
+
+ foo = entityManager.find(Foo.class, foo.getId());
+ entityManager.remove(foo);
+ flushAndClear();
+
+ assertThat(entityManager.find(Foo.class, foo.getId()), nullValue());
+ assertThat(entityManager.find(Bar.class, bar.getId()), nullValue());
+ }
+
+ @Test
+ @Transactional
+ public final void givenEntityIsDisassociated_thenOrphanRemovalIsApplied() {
+ Bar bar = new Bar("bar");
+ Baz baz = new Baz("baz");
+ bar.getBazList().add(baz);
+ entityManager.persist(bar);
+ flushAndClear();
+
+ bar = entityManager.find(Bar.class, bar.getId());
+ baz = bar.getBazList().get(0);
+ bar.getBazList().remove(baz);
+ flushAndClear();
+
+ assertThat(entityManager.find(Baz.class, baz.getId()), nullValue());
+ }
+
+ @Test
+ @Transactional
+ public final void givenEntityIsDeletedWithJpaBulkDeleteStatement_thenItIsNotInDB() {
+ Foo foo = new Foo("foo");
+ entityManager.persist(foo);
+ flushAndClear();
+
+ entityManager.createQuery("delete from Foo where id = :id")
+ .setParameter("id", foo.getId())
+ .executeUpdate();
+
+ assertThat(entityManager.find(Foo.class, foo.getId()), nullValue());
+ }
+
+ @Test
+ @Transactional
+ public final void givenEntityIsDeletedWithNativeQuery_thenItIsNotInDB() {
+ Foo foo = new Foo("foo");
+ entityManager.persist(foo);
+ flushAndClear();
+
+ entityManager.createNativeQuery("delete from FOO where ID = :id")
+ .setParameter("id", foo.getId())
+ .executeUpdate();
+
+ assertThat(entityManager.find(Foo.class, foo.getId()), nullValue());
+ }
+
+ @Test
+ @Transactional
+ public final void givenEntityIsSoftDeleted_thenItIsNotReturnedFromQueries() {
+ Foo foo = new Foo("foo");
+ entityManager.persist(foo);
+ flushAndClear();
+
+ foo = entityManager.find(Foo.class, foo.getId());
+ foo.setDeleted();
+ flushAndClear();
+
+ assertThat(entityManager.find(Foo.class, foo.getId()), nullValue());
+ }
+
+ private void flushAndClear() {
+ entityManager.flush();
+ entityManager.clear();
+ }
+}
diff --git a/spring-mvc-email/src/main/java/com/baeldung/spring/controllers/MailController.java b/spring-mvc-email/src/main/java/com/baeldung/spring/controllers/MailController.java
index 768a0f8e7b..ff828ca9ec 100644
--- a/spring-mvc-email/src/main/java/com/baeldung/spring/controllers/MailController.java
+++ b/spring-mvc-email/src/main/java/com/baeldung/spring/controllers/MailController.java
@@ -20,12 +20,10 @@ import java.util.Iterator;
import java.util.Map;
import java.util.Set;
-/**
- * Created by Olga on 7/20/2016.
- */
@Controller
@RequestMapping("/mail")
public class MailController {
+
@Autowired
public EmailServiceImpl emailService;
@@ -33,7 +31,6 @@ public class MailController {
private String attachmentPath;
@Autowired
- @Qualifier("templateSimpleMessage")
public SimpleMailMessage template;
private static final Map> labels;
diff --git a/spring-mvc-forms/pom.xml b/spring-mvc-forms/pom.xml
new file mode 100644
index 0000000000..370fd7feb2
--- /dev/null
+++ b/spring-mvc-forms/pom.xml
@@ -0,0 +1,99 @@
+
+
+
+ 4.0.0
+ com.baeldung
+ 0.1-SNAPSHOT
+ spring-mvc-forms
+
+ spring-mvc-forms
+ war
+
+
+
+ org.springframework
+ spring-webmvc
+ ${springframework.version}
+
+
+
+ javax.servlet
+ javax.servlet-api
+ ${javax.servlet-api.version}
+
+
+
+ javax.servlet.jsp
+ javax.servlet.jsp-api
+ ${javax.servlet.jsp-api.version}
+
+
+
+ javax.servlet
+ jstl
+ ${jstl.version}
+
+
+
+ org.hibernate
+ hibernate-validator
+ ${hibernate-validator.version}
+
+
+
+
+
+
+
+ spring-mvc-forms
+
+ true
+
+
+
+