Spring

Test Spring batch with @JpaDataTest

∥☆過路亽.° 提交于 2021-02-11 12:32:33
问题 I'm using spring batch 4.0 and i'm trying to test my batch. I would use embedded database h2 with @JpaDataTest but it doesn't work. When i add this annotation i got error java.lang.IllegalStateException: Existing transaction detected in JobRepository. Please fix this and try again (e.g. remove @Transactional annotations from client). @Transaction(propagation=Propagation.NEW_REQUIRED) on the @Test dosen't work. I tried to copy every annotations from @JpaDataTest and remove @Transaction

Embedded MongoDb not picked up for Application test

a 夏天 提交于 2021-02-11 12:24:41
问题 Application test AuthServiceApplicationTests.class is trying to run against local MongoDb instance which was setup for development and running behind the process. I shutdown this instance, and expected that it will run against embedded mongoDb with de.flapdoodle.embed.mongo . <!-- Integration Tests --> <dependency> <groupId>de.flapdoodle.embed</groupId> <artifactId>de.flapdoodle.embed.mongo</artifactId> <version>2.2.0</version> <scope>test</scope> </dependency> <!--/ Integration Tests -->

RequestReplyFuture<String, String, List<Product>> not mapped, Instead it mapped to ArrayList<LinkedHashMap>

岁酱吖の 提交于 2021-02-11 12:20:36
问题 I am using RequestReplyFuture<String, String, List> to mapped the response to List, the result is something like below @Service public class ProductProducer implements IProductProducer{ private final ReplyingKafkaTemplate<String, String, List<Product>> _replyTemplate; private static final Logger LOG = LoggerFactory.getLogger(ProductProducer.class); public ProductProducer(ReplyingKafkaTemplate<String, String, List<Product>> replyTemplate) { this._replyTemplate = replyTemplate; } @Override

How do I find base URL during Spring MVC startup?

青春壹個敷衍的年華 提交于 2021-02-11 12:07:30
问题 fellow programmers who lurks here at Stack Overflow. Today's question: How can I get the absolute baseUrl in Spring MVC Framework, from startup? I'm working with Spring MVC Framework for an application, and I'm in this situation: Let's say that I need to make objects of class Foo, inserted into a list. Every object contains an unique self-link (I'm using org.springframework.hateoas.Link for the real application, but that's beside the point). Example code: class Foo{ private int ID; private

Spring MVC----Validation(数据校验)

这一生的挚爱 提交于 2021-02-11 11:40:50
简化服务器验证 JSR-303 简介 JSR-303 是 JavaEE 6 中的一项子规范,叫做 Bean Validation,官方参考实现是 Hibernate Validator。 此实现与 Hibernate ORM 没有任何关系。JSR-303 用于对 Java Bean 中的字段的值进行验证。 Spring MVC 3.x 之中也大力支持 JSR-303,可以在控制器中使用注解的方式对表单提交的数据方便地验证。 Spring 4.0 开始支持 Bean Validation 功能。 JSR-303 基本的校验规则 空检查 @Null 验证对象是否为 null @NotNull 验证对象是否不为 null , 无法查检长度为 0 的字符串 @NotBlank 检查约束字符串是不是 Null 还有被 Trim 的长度是否大于 0,只对字符串,且会去掉前后空格 @NotEmpty 检查约束元素是否为 NULL 或者是 EMPTY 布尔检查 @AssertTrue 验证 Boolean 对象是否为 true @AssertFalse 验证 Boolean 对象是否为 false 长度检查 @Size(min=, max=) 验证对象( Array , Collection , Map , String )长度是否在给定的范围之内 @Length(min=, max=)

Java生鲜电商平台-监控模块的设计与架构

假装没事ソ 提交于 2021-02-11 10:44:25
点击上方蓝色“ 方志朋 ”,选择“设为星标” 回复“ 666 ”获取独家整理的学习资料! ‍ 来源: https://www.cnblogs.com/jurendage/p/9070442.html Java开源生鲜电商平台-监控模块的设计与架构,我们谈到监控,一般设计到两个方面的内容: 服务器本身的监控。(比如:linux服务器的CPU,内存,磁盘IO等监控) 业务系统的监控. (比如:业务系统性能的监控,SQL语句的监控,请求超时的监控,用户输入的监控,整个请求过程时间的监控,优化等等) 1. 服务器本身的监控 说明:由于Java开源生鲜电商平台采用的是阿里云的linux CentOS服务器,由于阿里云本身是有监控预警的,但是我们不可能时刻去看,最好有集成自己的系统监控, 最终在各种系统对比的过程中,选择了netdata这个工具,当然有一些软件比如:zabbix,negios等等都是可以的,但是我们服务器压力不算大,最终采用了更加轻量级的解决方案。 相关的安装与使用,大家自行百度处理,我这边就不列举出来了。 以下是相关的实际运营截图: 2. 业务监控 说明:任何一个业务系统都需要采用业务监控,抛异常,有error日志,短信预警,推送等等 Java内存 JavaCPU使用情况 用户Session数量 JDBC连接数 http请求、sql请求、jsp页面与业务接口方法(EJB3

Tomcat 7 + Annotations in log4j-api-2.11.1.jar

耗尽温柔 提交于 2021-02-11 10:24:54
问题 I get this exception from tomcat upon startup of the war file: Unable to process Jar entry [META-INF/versions/9/module-info.class] from Jar [jar:file:/C:/tomcat/apache-tomcat-7.0.61/webapps/monitormonitor/WEB-INF/lib/log4j-api-2.11.1.jar!/] for annotations org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 19 at org.apache.tomcat.util.bcel.classfile.Constant.readConstant(Constant.java:97) I tried to switch the log4j to an older version in the pom

Spring unit test objects autowired with null fields

纵饮孤独 提交于 2021-02-11 08:49:35
问题 I'm attempting to create unit tests for a rest service in my spring servlet. But when the controller object is created by @autowire, then all of its @autowired fields are null. My test class is as follows, using the SpringJUnit runner and context configuration set @ContextConfiguration(locations = "ExampleRestControllerTest-context.xml") @RunWith(SpringJUnit4ClassRunner.class) public class ExampleRestControllerTest { @Autowired private BaseService mockExampleService; @Autowired private

Spring RequestMapping 404 error

喜欢而已 提交于 2021-02-11 08:42:46
问题 I'm start new project in gradle. but continuously url mapping error come up. This is a 404 error. i'm try this error catch but this error don't understand please answer I'm not good at English. If you have any grammar errors, please understand me. Controller package sample.controller; import java.text.DateFormat; import java.util.Date; import java.util.Locale; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation

Reading ESRI shapefiles from the InputStream in Java

不问归期 提交于 2021-02-11 08:39:33
问题 I have a web application that is supposed to read a shapefile from a user's disk. I use a MultipartFile class (https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/multipart/MultipartFile.html) to upload it. As far as I understand, it is not possible to recover a file path from the MultipartFile . It causes a problem for me because I use the following code to interpret the shapefile content (I attach the constructor which is crucial): private ShapeFile(final File