美好的一天.以下代码:
class A{
private B b;
@Transactional
public SomeResult doSomething(){
SomeResult res = null;
try {
// do something
} catch (Exception e) {
res = b.saveResult();
}
return res ;
}
}
@Transactional(propagation = Propagation.REQUIRES_NEW)
class B{
public SomeResult saveResult(){
// save in db
}
}
Run Code Online (Sandbox Code Playgroud)
据我了解,如果方法中存在异常,doSomething
则不会回滚事务.以及如何使其滚动?并返回了SomeResult
我最近在我的项目中添加了 mapStruct。这个框架很酷,但我想不出一件事。
这是我的情况:我有类型的Profile
实体和字段Person
。我想使用ProfileDto
. 我正在void fromDto(ProfileDto dto, @MappingTarget Profile entity)
为此使用方法。问题是映射器总是创建新的人而不是使用profile
实体中的人
我的实体是:
public class Profile {
private Person person;
.. setters, getters and constructors
}
public class Person extends AbstractEntity {
private String name;
private String surname;
.. setters, getters and constructors
}
Run Code Online (Sandbox Code Playgroud)
到
public class ProfileDto extends AbstractDto {
private String name;
private String surname;
.. setters, getters and constructors
}
Run Code Online (Sandbox Code Playgroud)
我的映射器
public abstract class ProfileMapper {
@Mappings({
@Mapping(target …
Run Code Online (Sandbox Code Playgroud) 我在合同中定义了查询参数。我需要这个参数是可选的:
method 'GET'
url($(regex(urlRegex))) {
queryParameters {
parameter 'fitler': $(stub(regex(filterRegex)))
}
}
Run Code Online (Sandbox Code Playgroud)
我希望这个合同适用于带有过滤器的 URL/my/sample/url?fitler=some-filter-expression
和不带过滤器参数的URL /my/sample/url
。
我怎样才能做到这一点?这甚至可能吗?
我需要向用户显示所有正在运行的任务.每个任务都与特定的ID相关联.要执行任务,我使用a ThreadPoolExecutor
.每个线程都与id具有相同的名称.所以我只需要获取所有正在运行的队列和等待队列线程的列表.然后找到名称并显示它们.
我怎样才能做到这一点?
我的任务是使用发送请求,然后获取一些XML.
示例:请求:/api/ext/data.xml响应:一些XML
该应用程序使用Spring MVC,所以我只是编写了控制器方法,一切正常,但我还需要实现授权.此应用程序不使用Spring安全性.
我该怎么办?我应该使用会话来保存用户授权数据吗?
java ×4
concurrency ×1
hibernate ×1
mapstruct ×1
spring ×1
spring-mvc ×1
transactions ×1
wiremock ×1