Arch测试失败STANDARD_STREAMS。

huangapple go评论72阅读模式
英文:

Arch test failing STANDARD_STREAMS

问题

我有一个应用程序,它遵循ArchUnit规则,我得到了:

> NO_CLASSES_SHOULD_ACCESS_STANDARD_STREAMS

失败的规则 - 这意味着我不能使用标准的Java I/O流。但是我可以使用什么来替代呢?

我如何使用其他Java方法来避免这个架构规则,而不是使用标准流?因为我的架构规则正在失败。

英文:

I have app which folowing by archunit rules and I get:

> NO_CLASSES_SHOULD_ACCESS_STANDARD_STREAMS

failed rule - it's mean I can't use standard Java I/O Streams. But what I can use instead?

How I can avoid this architecture rule with another Java methods instead standard streams? Because My arch rules are failing

答案1

得分: 5

NO_CLASSES_SHOULD_ACCESS_STANDARD_STREAMS - 这是指,不应该使用System.out、System.err和printStackTrace方法:而应使用日志记录库。因此,我认为您需要删除所有的println System.out.println()

英文:

NO_CLASSES_SHOULD_ACCESS_STANDARD_STREAMS - is, the System.out, System.err, and printStackTrace methods: use a logging library instead. So I think you need remove all println System.out.println()

答案2

得分: 2

文档,即NO_CLASSES_SHOULD_ACCESS_STANDARD_STREAMS的javadoc,表示:

> 通常最佳实践是使用正确的日志记录而不是写入控制台
>
> - 在生产环境中无法配置控制台写入
> - 写入控制台是同步的,可能导致性能瓶颈
>
> 有关检查此规则的信息,请参阅GeneralCodingRules

您询问如何避免此架构规则。只需按照其建议操作:使用日志记录!

英文:

The documentation, i.e. the javadoc of NO_CLASSES_SHOULD_ACCESS_STANDARD_STREAMS, says:

> It is generally good practice to use correct logging instead of writing to the console.
>
> - Writing to the console cannot be configured in production
> - Writing to the console is synchronized and can lead to bottle necks
>
> For information about checking this rule, refer to GeneralCodingRules.

You asked how to avoid this architecture rule. Just do what it says: Use logging!

huangapple
  • 本文由 发表于 2020年9月11日 22:26:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/63849001.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定