遇到异常,以下是日志:org.springframework.beans.factory.BeanCreationException:创建名为“speaker”的bean时出错:注入自动装配依赖项失败;嵌套异常是 org.springframework.beans.factory.BeanCreationException:无法自动装配方法:public final void org.mybatis.spring.support.SqlSessionDaoSupport.setSqlSessionTemplate(org.mybatis.spring.SqlSessionTemplate); 嵌套异常是 java.lang.NoSuchMethodError: org.springframework.core.MethodParameter.getNestedParameterType()Ljava/lang/ClassJava网络服务:@WebServicepublic class voiceRecognition extends SpringBeanAutowiringSupport { @Autowired private Speaker speaker; @WebMethod public void test() { String userid = "111"; String enrollmentid = "111"; try{ String test1 = speaker.getEnrollmentId(userid); System.out.println(test1); } catch (Exception e) { e.printStackTrace(); } }}Speaker.java:package ph.com.aub.mapper;import org.apache.ibatis.annotations.Param;import org.springframework.stereotype.Service;@Servicepublic interface Speaker { public String getEnrollmentId(@Param("userid") String userid);}扬声器.xml:<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace = "ph.com.aub.mapper.Speaker"><select id = "getEnrollmentId" resultType = "string" parameterType = "string">Select enrollmentid from speakerids where userid = #{userid}</select></mapper>网页.xml:<?xml version = '1.0' encoding = 'windows-1252'?><web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
1 回答
繁星coding
TA贡献1797条经验 获得超4个赞
我相信您配置错误basePackage。MapperScannerConfigurer它应该是包含映射器类而不是映射器类本身的包。所以尝试将其更改basePackage为:
<bean id="mapperSpeaker" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="ph.com.aub.mapper" />
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactorySpeaker" />
</bean>
添加回答
举报
0/150
提交
取消