@SpringBootTest创建名称为'requestMappingHandlerAdapter'的bean时出错

时间:2019-09-20 23:57:40

标签: java spring hibernate spring-boot spring-mvc

我在使用弹簧靴时遇到问题。我收到错误错误,启动ApplicationContext。要显示条件报告,请在启用“调试”的情况下重新运行您的应用程序。 2019-09-22 10:16:18.954错误13282 --- [restartedMain] o.s.boot.SpringApplication:应用程序运行失败

org.springframework.beans.factory.BeanCreationException:在类路径资源[org / springframework / boot / autoconfigure / web / servlet / WebMvcAutoConfiguration $ EnableWebMvcConfiguration.class]中创建名称为'requestMappingHandlerAdapter'的bean时出错:通过工厂实例化Bean方法失败;嵌套的异常是org.springframework.beans.BeanInstantiationException:无法实例化[org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]:工厂方法'requestMappingHandlerAdapter'引发了异常;嵌套的异常是org.springframework.beans.factory.BeanCreationException:在类路径资源[org / springframework / boot / autoconfigure / web / servlet / WebMvcAutoConfiguration $ EnableWebMvcConfiguration.class]中创建名称为'mvcConversionService'的bean时出错:通过工厂实例化Bean方法失败;嵌套的异常是org.springframework.beans.BeanInstantiationException:无法实例化[org.springframework.format.support.FormattingConversionService]:工厂方法'mvcConversionService'引发了异常;嵌套的异常是org.springframework.beans.factory.BeanCreationException:创建名称为'requestRepository'的bean时出错:调用init方法失败;嵌套异常是java.lang.IllegalArgumentException:混合使用?参数和其他形式(例如?1)不受支持!

UserRepository

Object

UserRepositoryTests

else

RequestSatageRepository

catch

错误:

RuntimeException

1 个答案:

答案 0 :(得分:0)

我发现问题是,不再更改带有更改的?1和?2参数的@Query

** RequestRepository **

现在我的课是:

this

** RequestSatageRepository **

package com.spring.course.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import com.spring.course.domain.Request;
import com.spring.course.enums.RequestState;

@Repository
public interface RequestRepository extends JpaRepository<Request, Long>{

    public List<Request> findAllByOwnerId(Long id);

    @Query("UPDATE request SET state = :state WHERE id = :id")
    public Request updateStatus(Long id, RequestState state);

}

** UserRepository **

package com.spring.course.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import com.spring.course.domain.Request;
import com.spring.course.domain.RequestStage;
import com.spring.course.enums.RequestState;

@Repository
public interface RequestSatageRepository extends JpaRepository<RequestStage, Long>{

    public List<RequestStage> findAllByRequest(Long id);

    @Query("UPDATE request SET state = :state WHERE id = :id")
    public Request updateStatus(Long id, RequestState state);

}