每当尝试运行mvn install
时,在Spring Boot项目中,构建将因以下原因而失败:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
无法执行目标 org.apache.maven.plugins:Maven的编译器插件:3.3:编译 项目wave上的(default-compile):致命错误编译: 了java.lang.RuntimeException: com.sun.tools.javac.code.Symbol $ CompletionFailure:用于的类文件 org.springframework.security.ldap.DefaultSpringSecurityContextSource 找不到 - &gt; [帮助1]
有两件事解决了这个问题:
删除以下安全配置
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Inject
private UserDetailsService userDetailsService;
@Inject
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth
.userDetailsService(userDetailsService);
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.httpBasic()
.realmName("Wave")
.and()
.authorizeRequests()
.antMatchers(HttpMethod.POST, "/wave/service/employees/**").anonymous()
.antMatchers("/wave/service/**").authenticated()
.and()
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS);
}
}
对于coruse,删除配置不是一个选项,因为它会禁用我的应用程序的安全性
添加以下依赖
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-ldap</artifactId>
</dependency>
然而,在添加它时,错误消失了,出现了一个新的类似错误(只是指向另一个类):
无法执行目标 org.apache.maven.plugins:Maven的编译器插件:3.3:编译 项目wave上的(default-compile):致命错误编译: 了java.lang.RuntimeException: com.sun.tools.javac.code.Symbol $ CompletionFailure:用于的类文件 未找到org.springframework.security.openid.OpenIDAttribute - &gt; [救命 1]
再次修复此问题,我添加了以下依赖项:
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-openid</artifactId>
</dependency>
这再次解决了这个问题,但又出现了另一个错误:
无法执行目标 org.apache.maven.plugins:Maven的编译器插件:3.3:编译 项目wave上的(default-compile):致命错误编译: 了java.lang.RuntimeException: com.sun.tools.javac.code.Symbol $ CompletionFailure:用于的类文件 org.apache.http.Header not found - &gt; [帮助1]
最后,添加以下依赖项修复了所有问题:
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.1</version>
</dependency>
但是,我现在有多个依赖项,我不是使用。
还有其他方法可以解决这个问题吗?
答案 0 :(得分:6)
我通过替换
解决了这个问题<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa.modelgen.processor</artifactId>
<version>2.6.4</version>
<scope>provided</scope>
</dependency>
on
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>5.0.12.Final</version>
</dependency>
我认为org.eclipse.persistence.jpa.modelgen.processor中的这个问题
答案 1 :(得分:1)
删除您的依赖项并添加此项;我删除后,这对我来说很好。
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.1</version>
</dependency>
和
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-ldap</artifactId>
这是我的pom.xml文件
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<exclusions>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>2.0.9.RELEASE</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
</dependencies>