I am getting a nosuchbean exception as the title suggests, just adding text here to satisfy the mostly code thing.
Have put unlimited crypto jars in jre\lib\security
Key store created in application at src\main\resources and is called config-server.jks
application.properties (tried both key-stores location prop definitions)
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
using 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();
}
}
here is the 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>
}
Just ran into this problem too.
My best guess is that it is a bug in the latest version of Spring Cloud. I will open an issue on Spring Cloud project and link it here once finished.
I am using application.yml, not application.properties.
When you put any config for encrypt: * in application yml, it will give you this error. As a work-a-round, I tried putting the encrypt:* config in bootstrap.yml
After that, the Spring Boot app started successfully and it will have the RsaProperties Bean :)
Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With