【问题标题】:Spring boot Apache kafka binder project, application.properties spring.cloud.stream.kafka.binder. jaas properties are unknownSpring boot Apache kafka binder 项目,application.properties spring.cloud.stream.kafka.binder。 jaas 属性未知
【发布时间】:2017-10-24 06:09:22
【问题描述】:

我的项目 application.properties 发出警告。说

'spring.cloud.stream.kafka.binder.jaas.loginModule' 是一个未知数 属性。

我的项目 .pom 文件如下所示

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.shiwantha.test</groupId>
<artifactId>KafkaTestOne</artifactId>
<version>0.0.1-SNAPSHOT</version>
<parent>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-stream-binder-kafka-parent</artifactId>
    <version>1.1.0.RC2</version>
</parent>

<properties>
    <java.version>1.8</java.version>
    <spring-kafka.version>1.1.1.RELEASE</spring-kafka.version>
    <spring-integration-kafka.version>2.1.0.RELEASE</spring-integration-kafka.version>
    <kafka.version>0.10.0.0</kafka.version>
</properties>


<dependencies>
    <!-- spring-boot -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.kafka</groupId>
        <artifactId>spring-kafka</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.integration</groupId>
        <artifactId>spring-integration-kafka</artifactId>

    </dependency>
    <dependency>
        <groupId>org.apache.kafka</groupId>
        <artifactId>kafka_2.11</artifactId>

        <exclusions>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.apache.kafka</groupId>
        <artifactId>kafka-clients</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-stream-binder-kafka</artifactId>
        <version>1.1.0.RC2</version>
    </dependency>

    <dependency>

        <groupId>org.springframework.boot</groupId>

        <artifactId>spring-boot-starter-security</artifactId>

    </dependency>
    <dependency>

        <groupId>org.springframework.security</groupId>

        <artifactId>spring-security-test</artifactId>

        <scope>test</scope>

    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

</dependencies>



<build>
    <plugins>
        <!-- spring-boot-maven-plugin -->
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

<repositories>
    <repository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>http://repo.spring.io/libs-snapshot-local</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
        <releases>
            <enabled>false</enabled>
        </releases>
    </repository>
    <repository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>http://repo.spring.io/libs-milestone-local</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>spring-releases</id>
        <name>Spring Releases</name>
        <url>http://repo.spring.io/release</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>

我想创建一个 Spring Boot kafka 消费者应用程序,它与使用 kerberos 保护的 kafka 集群进行通信。我有密钥表文件。和kafka服务器信息。

spring.cloud.stream.kafka.binder.configuration.security.protocol=SASL_PLAINTEXT
spring.cloud.stream.kafka.binder.brokers = 10.48.148.44,10.48.148.45,10.48.148.46,10.48.148.47
spring.cloud.stream.kafka.bindings.input.consumer.autoCommitOffset = false



spring.cloud.stream.kafka.binder.jaas.loginModule = com.sun.security.auth.module.Krb5LoginModule
spring.cloud.stream.kafka.binder.jaas.controlFlag = required
spring.cloud.stream.kafka.binder.jaas.options.useKeyTab = true
spring.cloud.stream.kafka.binder.jaas.options.storeKey = true
spring.cloud.stream.kafka.binder.jaas.options.keyTab = src/main/resources/gitcc_kafka_user.keytab       
spring.cloud.stream.kafka.binder.jaas.options.principal = gitcc_kafka_user@DIALOG.DIALOGGSM.COM

请帮助我克服这些问题。我是新来的 。因此,如果您可以提供使用受 kerberos 保护的 kafka 服务器的示例项目,请提供

【问题讨论】:

  • 您使用的是什么 spring-boot 版本?你使用的是 1.1.0 版本的 kafka binder?您能否使用更高版本(可能是 1.3.0.RELEASE)尝试您的应用程序,看看问题是否仍然存在?
  • sobychacko 感谢您的回复。我使用了带有 kafka binder 1.3.0.RELEASE 的 spring boot starter parent 1.5.7 和 1.5.8。结果还是一样
  • @sobychacko 你能提供一个完整的 pom 文件,它可能没有任何问题。我尝试了许多版本的依赖项组合。请帮助我。谢谢。
  • 对我来说很好;看我的回答。

标签: java spring spring-boot apache-kafka kerberos


【解决方案1】:

这对我来说很好;您可以看到在调试器中设置的属性...

@SpringBootApplication
@EnableBinding(Sink.class)
public class So46903311Application {

    public static void main(String[] args) {
        SpringApplication.run(So46903311Application.class, args);
    }

}

spring.cloud.stream.kafka.binder.jaas.loginModule=testForSo46903311
spring.cloud.stream.kafka.binder.brokers=localhost:9092

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.8.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
    <spring-cloud.version>Dalston.SR4</spring-cloud.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-stream</artifactId>
        <version>1.3.0.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-stream-binder-kafka</artifactId>
        <version>1.3.0.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-stream-binder-kafka-core</artifactId>
        <version>1.3.0.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

【讨论】:

  • 真的很抱歉我的公司给了我另一个紧急项目,所以我找不到时间检查这个。 @Gary Russell 现在我在我的项目中使用了 spring kafka 2.0 版本。在那个版本中有一个用于插入 jaas 配置的 bean。它解决了我的身份验证问题。真的感谢那个版本。但我想知道,在上述解决方案中,您如何提供 jaas 配置。我想知道使用 apache kafka binder 和 spring kafka 有什么区别。我对这个领域真的很陌生,请帮助我
  • 我只是把属性放在application.properties。 kafka binder 下面使用spring-kafka
猜你喜欢
  • 2017-09-19
  • 2020-03-18
  • 2022-01-26
  • 1970-01-01
  • 1970-01-01
  • 2018-09-27
  • 1970-01-01
  • 1970-01-01
  • 2014-06-02
相关资源
最近更新 更多