小编Svi*_*ana的帖子

javax.annotation 类和 Java 11 JDK

我正在从 Java 8 迁移到 Java 11 并遇到了这个问题。我应该使用:

  • maven-compiler-plugin 2.5.1 与目标 1.8(在 java8 中编译 WAR)
  • tomcat9
  • 打开 JDK 11

但是在启动时不断出现错误:

合并bean定义后处理失败;嵌套异常是 java.lang.NoSuchMethodError: javax.annotation.Resource.lookup()Ljava/lang/String;

我找到了多种方法来修复它。尝试添加依赖项:

        <dependency>
            <groupId>javax.annotation</groupId>
            <artifactId>javax.annotation-api</artifactId>
            <version>1.3.2</version>
        </dependency>
Run Code Online (Sandbox Code Playgroud)

尝试添加扩展名:

   <extensions>
        <extension>
            <groupId>javax.annotation</groupId>
            <artifactId>javax.annotation-api</artifactId>
            <version>1.3.2</version>
        </extension>
    </extensions>
Run Code Online (Sandbox Code Playgroud)

这些都没有帮助。

这是 maven-compiler-plugin 配置:

    <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.5.1</version>
        <configuration>
            <source>1.8</source>
            <target>1.8</target>
            <encoding>UTF-8</encoding>
        </configuration>
    </plugin>
Run Code Online (Sandbox Code Playgroud)

请帮忙寻找解决办法!!

java maven maven-compiler-plugin java-11

16
推荐指数
4
解决办法
2万
查看次数

java.io.NotSerializableException:hudson.model.FreeStyleProject

我正在尝试在Jenkins中执行管道脚本.这是我的脚本:

import com.cloudbees.groovy.cps.NonCPS
@NonCPS
def getJobVariable(jobName,varName){ 
    job = Jenkins.instance.getItemByFullName(jobName)
        newJob = job.getLastBuild()
    return newJob.getEnvVars().get(varName,null)
}




node{
    stage 'props'

    api = build job: 'Props'
    buildID =  api.getNumber()
    build job: 'Parameterized', parameters: [[$class: 'StringParameterValue', name: 'string_parameter', value: getJobVariable('Props','filename')]];

}
Run Code Online (Sandbox Code Playgroud)

但我经常得到NotSerializableException.我猜,我的getJobVariable方法有问题.请帮忙

groovy jenkins jenkins-pipeline

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

FeignClient在春季靴子2

我试图从spring boot 1.5 tio 2.0迁移并遇到问题:我将spring-cloud-netflix-core的版本1.3.4.RELEASE更改2.0.1.RELEASE:

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-netflix-core</artifactId>
        <version>2.0.1.RELEASE</version>
    </dependency>
Run Code Online (Sandbox Code Playgroud)

不幸的是,feign库导入失败:

import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.feign.FeignAutoConfiguration;
import org.springframework.cloud.netflix.feign.FeignClient;
Run Code Online (Sandbox Code Playgroud)

在新的2.0.1版本中没有库.feign.我应该用什么呢?(由于与spring boot autoconfiguration冲突,因此不能保留旧的云版本)

java spring spring-boot netflix-feign spring-cloud-feign

9
推荐指数
2
解决办法
8722
查看次数

Jenkins EnvInject插件+管道工作

我想在我的管道工作中使用EnvInject插件.所以,我有可能设置复选框"为运行准备一个环境",但是没有动作"注入环境变量",就像在自由式作业中一样.我在"属性内容"块中声明了我的变量:在此输入图像描述

如何使用EnvInject在管道作业中注​​入环境变量?

groovy jenkins jenkins-pipeline

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

Spring Retry @Recover传递参数

我找不到任何有关需要采取行动的信息。我正在使用@Retryable注释和@Recover处理程序方法。像这样:

    @Retryable(value = {Exception.class}, maxAttempts = 5, backoff = @Backoff(delay = 10000))
    public void update(Integer id)
    {
        execute(id);
    }

    @Recover
    public void recover(Exception ex)
    {
        logger.error("Error when updating object with id {}", id);
    }
Run Code Online (Sandbox Code Playgroud)

问题是我不知道如何将我的参数“ id”传递给recovery()方法。有任何想法吗?提前致谢。

java spring recover spring-retry

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

领导者更改后,Spring kafka 消费者不提交到 kafka 服务器

我正在使用 spring-kafka 2.1.10.RELEASE。我有一个具有下一个属性的消费者(几乎复制了所有属性):

    auto.commit.interval.ms = 5000
    auto.offset.reset = earliest
    bootstrap.servers = [kafka1.local:9093, kafka2.local:9093, kafka3.local:9093]
    check.crcs = true
    client.id = kafkaListener-0
    connections.max.idle.ms = 540000
    enable.auto.commit = true
    exclude.internal.topics = true
    fetch.max.bytes = 52428800
    fetch.max.wait.ms = 500
    fetch.min.bytes = 1
    group.id = kafkaLisneterContainer
    heartbeat.interval.ms = 3000
    interceptor.classes = null
    internal.leave.group.on.close = true
    isolation.level = read_uncommitted
    max.poll.interval.ms = 300000
    max.poll.records = 50
    metadata.max.age.ms = 300000
    metrics.num.samples = 2
    metrics.recording.level = INFO
    metrics.sample.window.ms = 30000
    partition.assignment.strategy = [class org.apache.kafka.clients.consumer.RangeAssignor]
    receive.buffer.bytes = 65536
    reconnect.backoff.max.ms = …
Run Code Online (Sandbox Code Playgroud)

apache-kafka kafka-consumer-api kafka-producer-api spring-kafka

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

Spring @KafkaListener 和并发

我正在使用 spring boot + spring @KafkaListener。我期望的行为是:我的 kafka 侦听器在 10 个线程中读取消息。这样,如果其中一个线程挂起,其他消息将继续读取和处理消息。

我定义了bean

@Bean
public ConcurrentKafkaListenerContainerFactory<?, ?> kafkaListenerContainerFactory(
        ConcurrentKafkaListenerContainerFactoryConfigurer configurer,
        ConsumerFactory<Object, Object> kafkaConsumerFactory)
{

    ConcurrentKafkaListenerContainerFactory<Object, Object> factory = new ConcurrentKafkaListenerContainerFactory<>();
    configurer.configure(factory, kafkaConsumerFactory);
    factory.getContainerProperties().setMissingTopicsFatal(false);
    factory.getContainerProperties().setCommitLogLevel(LogIfLevelEnabled.Level.INFO);
    return factory;
}
Run Code Online (Sandbox Code Playgroud)

和弹簧引导配置:

spring.kafka.listener.concurrency=10
Run Code Online (Sandbox Code Playgroud)

我看到所有配置都有效,我在 jmx 中看到了我的 10 个线程:

在此处输入图片说明

但后来我做了这样的测试:

 @KafkaListener(topics = {
            "${topic.name}" }, clientIdPrefix = "${kafka.client.id.prefix}", idIsGroup = false, id = "${kafka.listener.name}", containerFactory = "kafkaListenerContainerFactory")
    public void listen(ConsumerRecord<String, String> record)
    {
        if(record.getVersion() < 3) {
            try {
                Thread.sleep(20000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            } …
Run Code Online (Sandbox Code Playgroud)

java spring apache-kafka spring-boot spring-kafka

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