【发布时间】:2019-01-21 17:04:29
【问题描述】:
正如标题所示,我得到了一个 nosuchbean 异常,只是在此处添加文本以满足大部分代码的需求。
在 jre\lib\security 中放置了无限的加密罐
在 src\main\resources 的应用程序中创建的密钥库,名为 config-server.jks
application.properties(尝试了两个 key-stores 位置属性定义)
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
使用 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();
}
}
这里是 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>
}
【问题讨论】:
-
这里是 keytool 命令: keytool -genkeypair -alias config-server-key -keyalg RSA -keysize 4096 -sigalg SHA512withRSA -dname "CN=Config Server,OU=Spring,O=MyOrg" - keypass my-k34-s3cr3t -keystore config-server.jks -storepass my-s70r3-s3cr3t
-
堆栈跟踪是什么?
-
不知道如何添加堆栈跟踪,因为注释中的字符有限
-
@user1346730 你应该编辑帖子以添加堆栈跟踪。
-
只是一个简单的问题。我看到密钥库位置在“config-server”中有一个空格,对吗?此外,错误堆栈跟踪将有很大帮助...
标签: java spring spring-boot spring-security