我发现是这样的:
"有状态 - 跟踪先前存储的用于当前交易的信息.
无状态 - 每次交易都像第一次完成一样进行.以前没有存储用于当前事务的信息.
在纯粹的无状态环境中,您不需要此会话ID.每个请求都包含服务器需要处理的所有信息.但是许多应用程序需要维护状态以跟踪会话是否经过身份验证以查看某些内容或跟踪用户正在做什么.您不希望通过网络为每个请求发送用户凭据."
我很困惑.因此,如果无状态会话与cookie保持状态,那么它意味着:无状态会话与cookie =会话状态?
另一个想法.我发现会话无状态是客户端会话和有状态是服务器端会话的信息.如果无状态会话不维护会话,我们如何讨论客户端会话?
我想知道如果json jackson vs jaxb更好的话.我做了一个研究,我知道(也许我错了)我们不应该使用jaxb来转换json(一些方案问题).另一方面,jaxb更适合xml?感谢帮助
如果JTA是API,我可以使用Hibernate作为JTA的实现吗?
我有一个Spring和Hibernate的应用程序,我想知道哪个框架应该负责事务,Spring或Hibernate?
我需要在我的应用程序中缓存一些数据,我正在考虑使用Ehcache.我有几个问题:
我正在使用Kotlin,Spring和Spek实现简单的微服务.我想测试我的存储库,但我想知道如何将repo注入spek测试用例.每个示例或教程都基于创建新的引用,如下所示:
object SampleTest : Spek({
describe("a calculator") {
val calculator = SampleCalculator()
it("should return the result of adding the first number to the second number") {
val sum = calculator.sum(2, 4)
assertEquals(6, sum)
}
it("should return the result of subtracting the second number from the first number") {
val subtract = calculator.subtract(4, 2)
assertEquals(2, subtract)
}
}
})
Run Code Online (Sandbox Code Playgroud)
总结一下,我不想这样做:
val calculator = SampleCalculator()
Run Code Online (Sandbox Code Playgroud)
我想实现这一目标
@Autowired
val calculator: SampleCalculator
Run Code Online (Sandbox Code Playgroud)
但我不能这样,因为我不能将服务自动服务到本地变量..任何解决方案?我是kotlin和spek的新人.
我有两段代码:
class PreciseRethrow {
public static void main(String[] str) {
try {
foo();
} catch (NumberFormatException ife) {
System.out.println(ife);
}
}
static private void foo() throws NumberFormatException {
try {
int i = Integer.parseInt("ten");
} catch (Exception e) {
throw e;
}
}
}
Run Code Online (Sandbox Code Playgroud)
并且:
class PreciseRethrow {
public static void main(String[] str) {
try {
foo();
} catch (NumberFormatException ife) {
System.out.println(ife);
}
}
static private void foo() throws NumberFormatException {
try {
int i = Integer.parseInt("ten");
} catch …Run Code Online (Sandbox Code Playgroud) 我们在两个节点上有Spring启动应用程序.现在我们想要每隔5秒在缓存中保留一些数据而不是呼叫外部服务.问题是如何在两个节点之间共享缓存?可能吗 ?或者也许每个节点创建两个单独的缓存?哪种方法更好?我认为维护共享缓存非常困难.谢谢你的任何提示
我不明白一件事。例如,如果 5 个用户登录您的应用程序,那么 spring security 创建 5 个不同的上下文?我对春天的背景有点困惑。
spring中的所有组件都是单例的(默认情况下)。那么,如果我创建一个组件,并且两个不同的经过身份验证的用户正在处理该组件,那么他们正在处理相同的数据?
我有这样的控制器处理程序:
@RequestMapping(method = POST, consumes = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "Add to basket")
@ApiResponses(value = {@ApiResponse(code = 200, message = "Successfully add to basket")})
@PreAuthorize("@securityService.hasUserAccess()")
public ResponseEntity addToBasket(@RequestBody @ItemAlreadyExistInBasket ProductEntity product) {
basketService.addToBasket(product);
return new ResponseEntity(HttpStatus.OK);
}
Run Code Online (Sandbox Code Playgroud)
认为是注释
@ItemAlreadyExistInBasket
从未被触发,我不知道为什么。这是我使用约束验证的注释
@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
@Retention(RUNTIME)
@Documented
@Constraint(validatedBy = ItemAlreadyExistInBasketConstraint.class)
public @interface ItemAlreadyExistInBasket {
String message() default "Item already exist in basket";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
}
public class ItemAlreadyExistInBasketConstraint implements ConstraintValidator<ItemAlreadyExistInBasket, ProductEntity> …Run Code Online (Sandbox Code Playgroud) 我试图指向这样的外部配置文件的路径:
--spring.config.location=file: C:/Users/some_user/workspace/repository1/payment-api/payment.yml
Run Code Online (Sandbox Code Playgroud)
而且不起作用。知道为什么吗?
我有这样的事情
@FeignClient(name = "${airport.service.name}")
Run Code Online (Sandbox Code Playgroud)
我有编译错误,例如
java.lang.IllegalStateException:服务ID不是合法的主机名($ {airport.service.name})
问题是如何将主机名形式传递applciation.yaml给FeignClient?