Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java &引用;Bean验证API位于类路径上,但找不到任何实现";防止启动_Java_Maven_Spring Boot_Spring Tool Suite - Fatal编程技术网

Java &引用;Bean验证API位于类路径上,但找不到任何实现";防止启动

Java &引用;Bean验证API位于类路径上,但找不到任何实现";防止启动,java,maven,spring-boot,spring-tool-suite,Java,Maven,Spring Boot,Spring Tool Suite,我正在使用Spring工具套件来处理Java中的ReST服务。但在第一点上,我无法启动我的第一个简单应用程序。请帮忙。我正在犯错误。[使用Java8、STS套件、Ubuntu 16.04、$Java_Home:/usr/lib/jvm/Java-8-oracle . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \

我正在使用Spring工具套件来处理Java中的ReST服务。但在第一点上,我无法启动我的第一个简单应用程序。请帮忙。我正在犯错误。[使用Java8、STS套件、Ubuntu 16.04、$Java_Home:/usr/lib/jvm/Java-8-oracle

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.4.2.RELEASE)

2018-01-28 09:37:14.658  INFO 7971 --- [           main] i.j.springbootstarter.CourseApiApp       : Starting CourseApiApp on rudresh-Vostro-14-3468 with PID 7971 (/home/rudresh/Documents/workspace-sts-3.9.2.RELEASE/course-api/target/classes started by rudresh in /home/rudresh/Documents/workspace-sts-3.9.2.RELEASE/course-api)
2018-01-28 09:37:14.667  INFO 7971 --- [           main] i.j.springbootstarter.CourseApiApp       : No active profile set, falling back to default profiles: default
2018-01-28 09:37:14.827  INFO 7971 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@6dde5c8c: startup date [Sun Jan 28 09:37:14 IST 2018]; root of context hierarchy
2018-01-28 09:37:16.551  WARN 7971 --- [           main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration$StringHttpMessageConverterConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'spring.http.encoding-org.springframework.boot.autoconfigure.web.HttpEncodingProperties': Initialization of bean failed; nested exception is javax.validation.ValidationException: Unable to create a Configuration, because no Bean Validation provider could be found. Add a provider like Hibernate Validator (RI) to your classpath.
2018-01-28 09:37:16.552  INFO 7971 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown
2018-01-28 09:37:16.568  INFO 7971 --- [           main] utoConfigurationReportLoggingInitializer : 

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2018-01-28 09:37:16.578 ERROR 7971 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

The Bean Validation API is on the classpath but no implementation could be found

Action:

Add an implementation, such as Hibernate Validator, to the classpath
下面是我的POM.xml文件。整个示例取自YouTube上的JavaBrains教程,仅供参考。我怀疑环境或Hibernate验证存在一些问题,我的系统中没有安装这些验证

<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>io.javabrains.springbootquickstart</groupId>
  <artifactId>course-api</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>Java Brains Course Api</name>



<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.4.2.RELEASE</version>
  </parent>
  <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>


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

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

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


</project>

"This is main class to start SpringBoot application. Although it does not do anything but it should at least redirect to browser Error page."


package io.javabrains.springbootstarter;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class CourseApiApp {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        SpringApplication.run(CourseApiApp.class, args);
    }

}

4.0.0
io.javabrains.springbootquickstart
课程api
0.0.1-快照
Java课程Api
org.springframework.boot
spring启动程序父级
1.4.2.1发布
UTF-8
UTF-8
1.8
org.springframework.boot
SpringBootStarterWeb
org.springframework.boot
弹簧起动试验
测试
org.springframework.boot
springbootmaven插件
“这是启动SpringBoot应用程序的主类。虽然它不执行任何操作,但至少应该重定向到浏览器错误页。”
包io.javabrains.springbootstarter;
导入org.springframework.boot.SpringApplication;
导入org.springframework.boot.autoconfigure.springboot应用程序;
@SpringBoot应用程序
公共课{
公共静态void main(字符串[]args){
//TODO自动生成的方法存根
run(courseapp.class,args);
}
}

/.m2/存储库中删除所有文件,然后尝试“maven-->安装”
project

文件似乎已损坏。因此,为了正确下载文件,请尝试以下步骤

根本不需要添加任何其他依赖项。“web”注入缺少的验证器

这里也有同样的问题,通过这个程序得到了解决。你只需要做一次,然后你就可以再做一次。(有时候,不要问为什么,当地的m2回购协议会被破坏)


希望能有所帮助。尊敬的Ivan,我也遇到了同样的问题。我的项目已投入生产将近一年,本周我需要进行一些更改,出乎意料的是,项目甚至无法构建。我通过在项目中添加以下依赖项来解决了这个问题

<dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>${your-desired-version-matching-project-own}</version>
</dependency>

org.hibernate
休眠验证器
${与project own匹配的所需版本}

注意:我使用的是spring starters依赖项,但仍然没有加载该依赖项。

在我的例子中,我添加了以下依赖项及其有效性,即使我不需要任何验证,也可能是Java更新导致了这个问题

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

org.springframework.boot
弹簧启动启动器验证

Main文件::
package io.javabrains.springbootstarter;导入org.springframework.boot.SpringApplication;导入org.springframework.boot.autoconfigure.springbootplication;@springbootplication公共类courseapp{public static void Main(String[]args){//TODO自动生成的方法stub SpringApplication.run(CourseAppp.class,args);}
您需要在pom.xml中添加以下依赖项:---org.hibernate hibernate validator Hi Dipak,谢谢您的评论。这次我也添加了该标记,但问题仍然是一样的。我的系统中同时安装了Eclipse和STS套件。这能解决问题吗?同样通过使用spring boot starter web,spring boot downloads hibernate验证程序依赖项。正如我所看到的,我在Maven dependencies列表中看到了它,但是你能在生成的jar文件中看到它吗?是的,这是最新的Spring引导中的一个更改。⬆️ 这是spring的官方答案……为什么启动jar lol中没有包含这个呢?我不太清楚为什么这些事情会变得不必要的复杂!仅仅添加
spring启动程序验证
也不足以让我的应用程序再次运行。但我不需要删除整个本地maven存储库。Del打开这个文件夹就足够了:
~/.m2/repository/org/hibernate/validator