小编Ash*_*oyi的帖子

无法在带有注解处理器配置的Gradle 5中使用Maven BOM

我正在尝试将Maven BOM与gradle 5.1.1一起使用,如下所述

ext {
  set('spring-boot-dependencies.version', '2.1.2.RELEASE')
}

apply plugin: 'java'

group 'com.acme'
version '1.0.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
  mavenCentral()
  jcenter()
}

dependencies {
  // maven bom
  implementation platform("org.springframework.boot:spring-boot-dependencies:${project.'spring-boot-dependencies.version'}")

  compileOnly('org.projectlombok:lombok')
  annotationProcessor('org.projectlombok:lombok')
}
Run Code Online (Sandbox Code Playgroud)

当我运行./gradlew dependencies --configuration=annotationProcessor&时./gradlew dependencies --configuration=compileOnly,我分别得到以下内容

annotationProcessor - Annotation processors and their dependencies for source set 'main'.
\--- org.projectlombok:lombok FAILED
Run Code Online (Sandbox Code Playgroud)
compileOnly - Compile only dependencies for source set 'main'.
+--- org.projectlombok:lombok FAILED
Run Code Online (Sandbox Code Playgroud)

奇怪的是,IntelliJ可以compileOnly正确解决依赖关系,但不能解决annotationProcessor

我对所发生的事情很困惑。任何帮助表示赞赏

Intellij Gradle视图

gradle annotation-processing spring-boot maven-bom

4
推荐指数
1
解决办法
698
查看次数

在 vscode 的装订线内添加右键菜单项

如何在 vscode 编辑器的装订线中添加右键菜单。

我想要在编辑器的装订线内右键单击时显示/隐藏行号选项。

我不确定这个的扩展点。

visual-studio-code vscode-extensions

3
推荐指数
1
解决办法
860
查看次数

使flex项目具有相等的宽度

如果你看下面的例子,我希望headers(h4.child-title)在父容器中具有相同的长度.

但我没有成功实现这一目标.

任何帮助表示赞赏.

.top-level {
  display: flex;
  flex-flow: row wrap;
}

.section {
  display: flex;
  flex-flow: row nowrap;
  border: 1px solid;
  margin-right: 12px;
  margin-top: 12px;
}

.section-child {
  display: flex;
  flex-flow: column nowrap;
  align-items: center;
  flex: 1 1 0;
}

.child-title {
  white-space: nowrap;
}

.vertical-separator {
  width: 1px;
  background-color: rgba(0, 0, 0, 0.3);
  margin: 8px;
}
Run Code Online (Sandbox Code Playgroud)
<div class="top-level">
  <section class="section">
    <div claas="section-child">
      <h4 class="child-title">Title</h4>
      <!--A lot more content here-->
    </div>
    <div class="vertical-separator"></div>
    <div class="section-child">
      <h4 class="child-title">Longer title</h4> …
Run Code Online (Sandbox Code Playgroud)

html css css3 flexbox css-grid

3
推荐指数
2
解决办法
1万
查看次数

将伪装和功能区日志重定向到 log4j2

我目前使用带有 log4j2 的 spring cloud netflix。log4j2 配置来自类路径中的 xml。当我运行应用程序时,我看到 feign 和功能区日志没有被重定向到配置中指定的记录器。我已经配置日志com.netflix.ribbon在登录包调试水平。

但是,为 spring 配置的日志正确重定向到指定的 appender,而ribbon 和 feign 则没有。

我将 gradle 与 spring-boot-starter-logging 忽略并添加了 spring-boot-starter-log4j2 作为我的构建的一部分。

我看到feign有一种我们可以配置 slf4j 的方法,但是由于我们使用注释驱动的 feign 支持,我无法将 feign 配置为使用 slf4j 进行日志记录。

任何帮助表示赞赏。

我的 log4j2.xml 看起来有点像

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
    <Properties>
        <Property name="log-path">logs</Property>
        <Property name="log-fileName">test</Property>
    </Properties>

    <Appenders>
        <Console name="console-log" target="SYSTEM_OUT">
            <PatternLayout pattern="[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n" />
        </Console>

        <RollingFile name="trace-log" fileName="${log-path}/${log-fileName}-trace.log" filePattern="${log-path}/${log-fileName}_trace-%d{yyyy-MM-dd}.log">
            <PatternLayout pattern="[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} …
Run Code Online (Sandbox Code Playgroud)

netflix log4j2 spring-boot spring-cloud netflix-feign

1
推荐指数
1
解决办法
5672
查看次数

为什么java String.split 忽略最后一个字符是基于最后一个字符拆分

如果我运行以下代码:

"testx".split("x")
Run Code Online (Sandbox Code Playgroud)

期望我们会得到{"test", ""},但 java 正在返回{"test"}

"xtest".split("x")返回{"", "test"}。任何想法为什么它的行为很奇怪(或)我有错误的理解吗?

这是我的 JDK 和系统信息:

JRE:1.8.0_152-release-1024-b6 amd64

JVM:JetBrains sro 的 OpenJDK 64 位服务器 VM

Linux 4.4.0-34-generic

java openjdk java-8

1
推荐指数
1
解决办法
1955
查看次数

使用静态方法泛型时不兼容的类型

当我尝试编译以下代码时,编译失败并出现以下错误.我不知道为什么它应该,因为我只返回一个实现合同的类

public interface Contract {
  static <T extends Contract> T get() {
    return new ConcreteContract();
  }
}

class ConcreteContract implements Contract {
}
Run Code Online (Sandbox Code Playgroud)
Contract.java:3: error: incompatible types: ConcreteContract cannot be converted to T
    return new ConcreteContract();
           ^
  where T is a type-variable:
    T extends Contract declared in method <T>get()
1 error
Run Code Online (Sandbox Code Playgroud)

有没有人知道为什么java表现这种方式(或)我错过了一些明显的东西

PS:在发布此查询之前,我已在SO中阅读了超过10个热门搜索

java generics static-methods

0
推荐指数
1
解决办法
137
查看次数