没有'org.springframework.cloud.bootstrap.encrypt.RsaProperties'类型的限定bean

use*_*730 5 java spring spring-security spring-boot

标题建议我得到一个nosuchbean异常,只是在这里添加文本以满足大多数代码的东西.

在jre\lib\security中放置了无限量的加密罐

在src\main\resources中的应用程序中创建的密钥库,称为config-server.jks

application.properties(尝试了两个密钥库位置道具定义)

server.port=8888
spring.cloud.config.server.git.uri=ssh://git@v00bitbucket:7999/proj/config-server.git
spring.cloud.config.server.git.clone-on-start=true
security.user.name=Joe
security.user.password={bcrypt}$2a$10$7H8tnjyf/Mn90eAZADruterXJ.t.GQP4WgRIZ8cwnRsMmhZhCtS1a
#encrypt.key-store.location=classpath:/config-server.jks
encrypt.key-store.location=file://C:/myAppDir/config- server/src/main/resources/config-server.jks
encrypt.key-store.password=my-s70r3-s3cr3t
encrypt.key-store.alias=config-server-key
encrypt.key-store.secret=my-k34-s3cr3t
Run Code Online (Sandbox Code Playgroud)

使用java 1.8.0_77

@RunWith(SpringRunner.class)
@SpringBootTest
public class ConfigServerApplicationTests {    
    @Test
    public void contextLoads() {
    }
}    


@SpringBootApplication
@EnableConfigServer
public class ConfigServerApplication {
    public static void main(String[] args) {
        SpringApplication.run(ConfigServerApplication.class, args);
    }
}

@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
    @Value("${security.user.name}")
    private String authUser;
    @Value("${security.user.password}")
    private String authPassword; // this password is encoded
    @Autowired
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth.inMemoryAuthentication().passwordEncoder(PasswordEncoderFactories.createDelegatingPasswordEncoder())
        .withUser(authUser).password(authPassword).roles("User");
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests().anyRequest().fullyAuthenticated();
        http.httpBasic();
        http.csrf().disable();
    }
}
Run Code Online (Sandbox Code Playgroud)

这是pom {

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.4.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>Finchley.SR1</spring-cloud.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-config-server</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-config</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-rsa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)

}

mik*_*477 6

只是也遇到了这个问题。

我最好的猜测是,这是最新版本的Spring Cloud中的错误。我将在Spring Cloud项目中打开一个问题,并在完成后将其链接到此处。

我正在使用application.yml,而不是application.properties。

当您在应用yml中放置用于加密的任何配置:*时,它将出现此错误。作为一项工作,我尝试将crypto:*配置放入bootstrap.yml中

之后,Spring Boot应用程序成功启动,并且将具有RsaProperties Bean :)

希望这可以帮助!