Skip to main content

Posts

Showing posts with the label Java

Parse Text from PDF with OCR using Apache Tika

Apache Tika is opensource software working about OCR from PDF, Image file. In this example is using Java Maven project to work with Apache Tika. First of all, you need to add dependencies for using Apache Tika by add these dependencies into pom.xml <dependency> <groupId> org.apache.tika </groupId> <artifactId> tika-parsers </artifactId> <version> 1.18 </version> </dependency> <dependency> <groupId> com.levigo.jbig2 </groupId> <artifactId> levigo-jbig2-imageio </artifactId> <version> 2.0 </version> </dependency> <dependency> <groupId> com.github.jai-imageio </groupId> <artifactId> jai-imageio-core </artifactId> <version> 1.4.0 </version> </dependency> <depende...

How to create controller to support JSON in Spring Boot

You can create your controller to support application/json request in many way. And if your request is not match with your controller that request will be fail. Controller to support JSON request and HEADER variables. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 package com.myexample; import java.util.HashMap; import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; @RestController public class RecognizedReceiver { private static final Logger logger = LoggerFactory.getLogger(RecognizedReceiver.class); @RequestMapping(...

การใช้ Jetty แทน Tomcat ใน Spring Boot 2

วิธีการใช้ Jetty แทน Tomcat ใน Spring Boot สามารถทำได้โดย ทำการแก้ไข POM.XML ในส่วนของ spring-boot-web-starter โดยให้ Exclude spring-boot-starter-tomcat และใส่  spring-boot-starter-jetty ลงไป ตามตัวอย่างด้านล่าง 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 <dependency> <groupId> org.springframework.boot </groupId> <artifactId> spring-boot-starter-web </artifactId> <exclusions> <exclusion> <groupId> org.springframework.boot </groupId> <artifactId> spring-boot-starter-tomcat </artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId> org.springframework.boot </groupId> <artifactId> spring-boot-starter-jetty </artifactId> </dependency> จากนั้นสามารถทดสอบรัน Spring Boot App ที่ใช้ Jetty ได้ด้วยคำสั่ง  > mvn spring-boot:run ได้ตามปกติ  และสามารถถกำหนดค่าของ Address ที่ใช้ได้ใน...