SpringMVC单独封装service时报空指针异常NullPointerException

不想醒来 2017-05-02 10:12:09

package com.shanshan.bo.utils;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;

import com.shanshan.bo.pojo.SsFundDimBank;
import com.shanshan.bo.pojo.SsFundDimCurrencyType;
import com.shanshan.bo.pojo.SsbiUser;
import com.shanshan.bo.service.SsFundDimBankService;
import com.shanshan.bo.service.SsFundDimCurrencyTypeService;
import com.shanshan.bo.service.SsbiUserService;

@Controller
public class DataFactoryUtil {

@Resource
private SsbiUserService userService;

@Resource
private SsFundDimBankService bankService;

@Resource
private SsFundDimCurrencyTypeService currencyTypeService;

/**
* 根据用户名去数据库查询用户并返回
* Ps:暂不考虑用户名重复的问题
* @param username
* @return User
*/
public SsbiUser selectByUsername(String username) {
if (username != null && !("".equals(username))) {
try {
return userService.selectByUserCode(username);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
return null;
}

/**
* 查询所有的银行数据并返回
*/
public static List<SsFundDimBank> selectAllBank() {
return (new DataFactoryUtil()).bankService.selectAll();
}

/**
* 查询所有的币制数据并返回
*/
public static List<SsFundDimCurrencyType> selectAllCurrencyType() {
return (new DataFactoryUtil()).currencyTypeService.selectAll();
}
}



出问题的代码就上面这部分。
一开始我是在一个LoginController单独写的(springmvc注入的控制层)
@Resource
private SsbiUserService userService;
和 selectByUsername 这个方法,当时使用是没有问题的。(包括另外两个bankService和currencyTypeService)
然后我发现我在其他地方也需要调用,所以我就想把这部分功能单独封装出来,要用的时候调用一下就好了。
但是封装后问题就出现了,获取数据一直出错,debug一下发现是java.lang.NullPointerException报错,但是我不理解为什么会这样,而且不知道怎么解决。
求帮助~
...全文
1642 38 打赏 收藏 转发到动态 举报
写回复
用AI写文章
38 条回复
切换为时间正序
请发表友善的回复…
发表回复
stonesingsong 2017-06-07
  • 打赏
  • 举报
回复
引用 37 楼 u010691963 的回复:
ok,问题解决。最后的结论是调用service不能用new!
我把这部分功能代码封装成工具类以后,不论是在外部调用的时候,还是在该工具类中用单例模式写入到构造方法中,都绕不够new这个过程,这样就会导致找不到于是报错空指针异常。
33楼的回答虽然没看清楚我的代码,但是他提供的解决方向是对的。参考他提供的文章 http://blog.csdn.net/p793049488/article/details/37819121 采用静态工具类中使用注解注入service的解决方案,最终解决了问题。
该方案的关键在于定义一个内部的类对象,然后在初始化的时候把service的值赋值给内部变量userService等。
我测试了一下,@PostConstruct注解的方法会随着tomcat启动的时候运行加载,这意味着我的userService也会加载进去,等于在后面使用的时候不需要new,自然就没有了找不到对象的问题,避免了空指针异常。

private static DataFactoryUtil dataFactoryUtil;

@PostConstruct
public void init() {
dataFactoryUtil = this;
dataFactoryUtil.userService = this.userService;
}

你好,我也遇到了这个问题,按照你的方法没有还是报空指针,请假下是什么问题,下面是我的代码
不想醒来 2017-05-03
  • 打赏
  • 举报
回复
ok,问题解决。最后的结论是调用service不能用new! 我把这部分功能代码封装成工具类以后,不论是在外部调用的时候,还是在该工具类中用单例模式写入到构造方法中,都绕不够new这个过程,这样就会导致找不到于是报错空指针异常。 33楼的回答虽然没看清楚我的代码,但是他提供的解决方向是对的。参考他提供的文章 http://blog.csdn.net/p793049488/article/details/37819121 采用静态工具类中使用注解注入service的解决方案,最终解决了问题。 该方案的关键在于定义一个内部的类对象,然后在初始化的时候把service的值赋值给内部变量userService等。 我测试了一下,@PostConstruct注解的方法会随着tomcat启动的时候运行加载,这意味着我的userService也会加载进去,等于在后面使用的时候不需要new,自然就没有了找不到对象的问题,避免了空指针异常。

private static DataFactoryUtil dataFactoryUtil;
	
	@PostConstruct
	public void init() {
		dataFactoryUtil = this;
		dataFactoryUtil.userService = this.userService;
	}
giya射手 2017-05-03
  • 打赏
  • 举报
回复
引用 31 楼 u010691963 的回复:
[quote=引用 29 楼 qq_27333559 的回复:] [quote=引用 27 楼 u010691963 的回复:] [quote=引用 22 楼 qq_27333559 的回复:] 你的userService是空的,检查一下你的配置是否注入了userService
能否说的详细点?现在我也不知道还有哪里需要配置的,问题是我在LoginController里面写上直接用是没有问题的,但是封装出来用就不行。。
引用

@Resource
private SsbiUserService userService;

public SsbiUser selectByUsername(String username) {
		if (username != null && !("".equals(username))) {
			try {
				return userService.selectByUserCode(username);
			} catch (Exception e) {
				// TODO: handle exception
				e.printStackTrace();
			}
		}
		return null;
	}
这两段代码直接在LoginController用是可以的,我复制黏贴过来就不行了。还有哪里需要配置的吗?[/quote] 在你的xxx.xml中加 <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="你封装的方法类"/> <property name="markerInterface" value="你的mapple的路劲(即selectByUserCode方法的路劲)"/> </bean>[/quote] 你说的是mybatis的配置文件吗?我原先有这个配置

<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<property name="basePackage" value="com.shanshan.bo.dao" />
		<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
	</bean>
你是说让我在这里面加上这句吗? <property name="markerInterface" value="com.shanshan.bo.dao.SsbiUserMapper"/> 但是我加上后运行tomcat直接就报错了。 具体的项目路径配置我稍后在后面再开一层单独贴一下,你看看吧[/quote] 就在你的mybatis中再添加 <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="你封装的controller路径" /> <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property> </bean> 就这样试试
不想醒来 2017-05-03
  • 打赏
  • 举报
回复
引用 33 楼 my_daisy 的回复:
你的查询方法是static的,可以参考一下http://blog.csdn.net/p793049488/article/details/37819121这篇文章
你好,我觉得这篇文章说的方法也许是能解决我的问题,但是有一部分代码的作用我不太明白,你能帮忙解释下吗?

public void setUserInfo(IOpeLogService opeLogService) {  
        this.opeLogService = opeLogService;  
    }
皓月_银辉 2017-05-02
  • 打赏
  • 举报
回复
引用 30 楼 不想醒来的回复:
[quote=引用 28 楼 qq_22656325 的回复:] [quote=引用 27 楼 u010691963 的回复:] [quote=引用 22 楼 qq_27333559 的回复:] 你的userService是空的,检查一下你的配置是否注入了userService
能否说的详细点?现在我也不知道还有哪里需要配置的,问题是我在LoginController里面写上直接用是没有问题的,但是封装出来用就不行。。
引用

@Resource
private SsbiUserService userService;

public SsbiUser selectByUsername(String username) {
		if (username != null && !("".equals(username))) {
			try {
				return userService.selectByUserCode(username);
			} catch (Exception e) {
				// TODO: handle exception
				e.printStackTrace();
			}
		}
		return null;
	}
这两段代码直接在LoginController用是可以的,我复制黏贴过来就不行了。还有哪里需要配置的吗?[/quote] 我不理解你的复制出来是什么意思?复制到什么地方了?[/quote] 就是我说了好几遍的LoginController啊!我一开始是直接在LoginController里面写的,可以用。后来我发现还有其他地方也需要用到,所以我想把这部分功能封装出来,于是复制黏贴,结果报错不能用。明白了吗?[/quote] 额 不好意思,看错了,才看到你这是工具类,,,那我就怀疑你在logincontroller里直接new了一个util
  • 打赏
  • 举报
回复
查看springmvc注解扫描路径
一个治疗术 2017-05-02
  • 打赏
  • 举报
回复
spring mvc 中在Controller中可以不可以调用另一个Controller层中的方法,只能跳转。 如果你需要调的是方法,请抽离出来,不要放在Controller里面,因为这不符合MVC设计的理念。
一个治疗术 2017-05-02
  • 打赏
  • 举报
回复
@Controller 去掉
不想醒来 2017-05-02
  • 打赏
  • 举报
回复
自己顶一下~ 准备再次强调下! 一样的写法,一开始写在Controller里面的时候是可以用,没有问题的! 后来我封装出来调用的时候才出现的报错
故人西辞_ 2017-05-02
  • 打赏
  • 举报
回复
你的查询方法是static的,可以参考一下http://blog.csdn.net/p793049488/article/details/37819121这篇文章
不想醒来 2017-05-02
  • 打赏
  • 举报
回复
好像我没有说明项目配置情况对各位的解答造成了不便,我这里单独一层贴出来说明一下吧。
首先是项目的整体路径和分布


然后是个别大家可能需要看到的配置文件
web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 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">

<!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring/root-context.xml,
<!-- mybatis的配置文件 -->
/WEB-INF/mybatis/mybatis-spring-multiDB.xml
</param-value>
</context-param>

<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<!-- Processes application requests -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

</web-app>


springmvc的配置文件

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->

<!-- Enables the Spring MVC @Controller programming model -->
<annotation-driven />

<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
<resources mapping="/resources/**" location="/resources/" />

<!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>

<context:component-scan base-package="com.shanshan.bo" />



</beans:beans>


mybatis的配置文件(因为我是一个项目连接2个数据库,所以用了动态连接配置)

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">

<!-- 自动扫描 -->
<context:component-scan base-package="com.shanshan.bo" />
<!-- 引入配置文件 -->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:jdbc.properties" />
</bean>

<!--统一的dataSource-->
<bean id="dynamicDataSource" class="com.shanshan.bo.utils.DynamicDataSource" >
<property name="targetDataSources">
<map key-type="java.lang.String">
<!--通过不同的key决定用哪个dataSource-->
<entry value-ref="ss0323DataSource" key="ss0323DataSource"></entry>
<entry value-ref="mdataDataSource" key="mdataDataSource"></entry>
</map>
</property>
<!--设置默认的dataSource-->
<property name="defaultTargetDataSource" ref="ss0323DataSource">
</property>
</bean>

<bean id="ss0323DataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${ss0323.driver}" />
<property name="url" value="${ss0323.url}" />
<property name="username" value="${ss0323.username}" />
<property name="password" value="${ss0323.password}" />
<!-- 初始化连接大小 -->
<property name="initialSize" value="${initialSize}"></property>
<!-- 连接池最大数量 -->
<property name="maxActive" value="${maxActive}"></property>
<!-- 连接池最大空闲 -->
<property name="maxIdle" value="${maxIdle}"></property>
<!-- 连接池最小空闲 -->
<property name="minIdle" value="${minIdle}"></property>
<!-- 获取连接最大等待时间 -->
<property name="maxWait" value="${maxWait}"></property>
</bean>

<bean id="mdataDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${mdata.driver}" />
<property name="url" value="${mdata.url}" />
<property name="username" value="${mdata.username}" />
<property name="password" value="${mdata.password}" />
<!-- 初始化连接大小 -->
<property name="initialSize" value="${initialSize}"></property>
<!-- 连接池最大数量 -->
<property name="maxActive" value="${maxActive}"></property>
<!-- 连接池最大空闲 -->
<property name="maxIdle" value="${maxIdle}"></property>
<!-- 连接池最小空闲 -->
<property name="minIdle" value="${minIdle}"></property>
<!-- 获取连接最大等待时间 -->
<property name="maxWait" value="${maxWait}"></property>
</bean>


<!-- spring和MyBatis完美整合,不需要mybatis的配置映射文件 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dynamicDataSource" />
<!-- mybatis的配置文件 -->
<!-- <property name="configLocation" value="/WEB-INF/mybatis/mybatis-config.xml"></property> -->
<!-- 自动扫描mapping.xml文件 -->
<property name="mapperLocations" value="classpath:com/shanshan/bo/mapping/*.xml"></property>
</bean>

<!-- DAO接口所在包名,Spring会自动查找其下的类 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.shanshan.bo.dao" />
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
</bean>

<!-- (事务管理)transaction manager, use JtaTransactionManager for global tx -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="ss0323DataSource" />
</bean>

</beans>


如果还有什么想看的文件或者配置,也可以问,只要能解决问题就行
不想醒来 2017-05-02
  • 打赏
  • 举报
回复
引用 29 楼 qq_27333559 的回复:
[quote=引用 27 楼 u010691963 的回复:] [quote=引用 22 楼 qq_27333559 的回复:] 你的userService是空的,检查一下你的配置是否注入了userService
能否说的详细点?现在我也不知道还有哪里需要配置的,问题是我在LoginController里面写上直接用是没有问题的,但是封装出来用就不行。。
引用

@Resource
private SsbiUserService userService;

public SsbiUser selectByUsername(String username) {
		if (username != null && !("".equals(username))) {
			try {
				return userService.selectByUserCode(username);
			} catch (Exception e) {
				// TODO: handle exception
				e.printStackTrace();
			}
		}
		return null;
	}
这两段代码直接在LoginController用是可以的,我复制黏贴过来就不行了。还有哪里需要配置的吗?[/quote] 在你的xxx.xml中加 <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="你封装的方法类"/> <property name="markerInterface" value="你的mapple的路劲(即selectByUserCode方法的路劲)"/> </bean>[/quote] 你说的是mybatis的配置文件吗?我原先有这个配置

<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<property name="basePackage" value="com.shanshan.bo.dao" />
		<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
	</bean>
你是说让我在这里面加上这句吗? <property name="markerInterface" value="com.shanshan.bo.dao.SsbiUserMapper"/> 但是我加上后运行tomcat直接就报错了。 具体的项目路径配置我稍后在后面再开一层单独贴一下,你看看吧
不想醒来 2017-05-02
  • 打赏
  • 举报
回复
引用 28 楼 qq_22656325 的回复:
[quote=引用 27 楼 u010691963 的回复:] [quote=引用 22 楼 qq_27333559 的回复:] 你的userService是空的,检查一下你的配置是否注入了userService
能否说的详细点?现在我也不知道还有哪里需要配置的,问题是我在LoginController里面写上直接用是没有问题的,但是封装出来用就不行。。
引用

@Resource
private SsbiUserService userService;

public SsbiUser selectByUsername(String username) {
		if (username != null && !("".equals(username))) {
			try {
				return userService.selectByUserCode(username);
			} catch (Exception e) {
				// TODO: handle exception
				e.printStackTrace();
			}
		}
		return null;
	}
这两段代码直接在LoginController用是可以的,我复制黏贴过来就不行了。还有哪里需要配置的吗?[/quote] 我不理解你的复制出来是什么意思?复制到什么地方了?[/quote] 就是我说了好几遍的LoginController啊!我一开始是直接在LoginController里面写的,可以用。后来我发现还有其他地方也需要用到,所以我想把这部分功能封装出来,于是复制黏贴,结果报错不能用。明白了吗?
giya射手 2017-05-02
  • 打赏
  • 举报
回复
引用 27 楼 u010691963 的回复:
[quote=引用 22 楼 qq_27333559 的回复:] 你的userService是空的,检查一下你的配置是否注入了userService
能否说的详细点?现在我也不知道还有哪里需要配置的,问题是我在LoginController里面写上直接用是没有问题的,但是封装出来用就不行。。
引用

@Resource
private SsbiUserService userService;

public SsbiUser selectByUsername(String username) {
		if (username != null && !("".equals(username))) {
			try {
				return userService.selectByUserCode(username);
			} catch (Exception e) {
				// TODO: handle exception
				e.printStackTrace();
			}
		}
		return null;
	}
这两段代码直接在LoginController用是可以的,我复制黏贴过来就不行了。还有哪里需要配置的吗?[/quote] 在你的xxx.xml中加 <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="你封装的方法类"/> <property name="markerInterface" value="你的mapple的路劲(即selectByUserCode方法的路劲)"/> </bean>
皓月_银辉 2017-05-02
  • 打赏
  • 举报
回复
引用 27 楼 u010691963 的回复:
[quote=引用 22 楼 qq_27333559 的回复:] 你的userService是空的,检查一下你的配置是否注入了userService
能否说的详细点?现在我也不知道还有哪里需要配置的,问题是我在LoginController里面写上直接用是没有问题的,但是封装出来用就不行。。
引用

@Resource
private SsbiUserService userService;

public SsbiUser selectByUsername(String username) {
		if (username != null && !("".equals(username))) {
			try {
				return userService.selectByUserCode(username);
			} catch (Exception e) {
				// TODO: handle exception
				e.printStackTrace();
			}
		}
		return null;
	}
这两段代码直接在LoginController用是可以的,我复制黏贴过来就不行了。还有哪里需要配置的吗?[/quote] 我不理解你的复制出来是什么意思?复制到什么地方了?
不想醒来 2017-05-02
  • 打赏
  • 举报
回复
引用 22 楼 qq_27333559 的回复:
你的userService是空的,检查一下你的配置是否注入了userService
能否说的详细点?现在我也不知道还有哪里需要配置的,问题是我在LoginController里面写上直接用是没有问题的,但是封装出来用就不行。。
引用

@Resource
private SsbiUserService userService;

public SsbiUser selectByUsername(String username) {
		if (username != null && !("".equals(username))) {
			try {
				return userService.selectByUserCode(username);
			} catch (Exception e) {
				// TODO: handle exception
				e.printStackTrace();
			}
		}
		return null;
	}
这两段代码直接在LoginController用是可以的,我复制黏贴过来就不行了。还有哪里需要配置的吗?
不想醒来 2017-05-02
  • 打赏
  • 举报
回复
引用 24 楼 qq_22656325 的回复:
[quote=引用 23 楼 u010691963 的回复:] [quote=引用 20 楼 qq_22656325 的回复:] [quote=引用 19 楼 u010691963 的回复:] [quote=引用 16 楼 qq_22656325 的回复:] SsbiUserService 这个service里是不是忘加注解了?
我上面贴的代码里不是加了@Resource注解了吗?难道还有别的地方需要加注解吗?[/quote] 那个service类里不是应该有@service注解吗?[/quote] service里面没有注解吧?serviceImpl里面倒是有@service注解的[/quote] 额 说的就是impl里的,理解意思就好了。。你这个service没有注入进来,他是null,所以有空指针,重点看为啥没注入进来[/quote] 是的,问题还是我在LoginController里面直接用是没有问题的,但是封装出来用就吧不行。。。
不想醒来 2017-05-02
  • 打赏
  • 举报
回复
引用 21 楼 aschouas 的回复:
[quote=引用 17 楼 u010691963 的回复:]
[quote=引用 14 楼 aschouas 的回复:]
[quote=引用 13 楼 u010691963 的回复:]
[quote=引用 12 楼 aschouas 的回复:]
spring mvc 中在Controller中可以不可以调用另一个Controller层中的方法,只能跳转。
加这个@Component

试了下也不行,而且我上面刚刚说了,一开始我没加@Controller的时候也报错,所以我觉得不是加Controller的问题[/quote]
那你username 进来的时候有值吗[/quote]
username值传入没问题。而且你看我上面代码,有个if判断的。username有值然后执行的时候报错了[/quote]
你确定你debug到35行的时候username是没问题的???我不信[/quote]

看到了吗?debug到if语句里面的时候,username是有值的
皓月_银辉 2017-05-02
  • 打赏
  • 举报
回复
引用 23 楼 u010691963 的回复:
[quote=引用 20 楼 qq_22656325 的回复:] [quote=引用 19 楼 u010691963 的回复:] [quote=引用 16 楼 qq_22656325 的回复:] SsbiUserService 这个service里是不是忘加注解了?
我上面贴的代码里不是加了@Resource注解了吗?难道还有别的地方需要加注解吗?[/quote] 那个service类里不是应该有@service注解吗?[/quote] service里面没有注解吧?serviceImpl里面倒是有@service注解的[/quote] 额 说的就是impl里的,理解意思就好了。。你这个service没有注入进来,他是null,所以有空指针,重点看为啥没注入进来
不想醒来 2017-05-02
  • 打赏
  • 举报
回复
引用 20 楼 qq_22656325 的回复:
[quote=引用 19 楼 u010691963 的回复:] [quote=引用 16 楼 qq_22656325 的回复:] SsbiUserService 这个service里是不是忘加注解了?
我上面贴的代码里不是加了@Resource注解了吗?难道还有别的地方需要加注解吗?[/quote] 那个service类里不是应该有@service注解吗?[/quote] service里面没有注解吧?serviceImpl里面倒是有@service注解的
加载更多回复(18)

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧