Guest User

Untitled

a guest
Mar 27th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.02 KB | None | 0 0
  1. [ERROR] COMPILATION ERROR :
  2. [INFO] -------------------------------------------------------------
  3. [ERROR] /C:/Users/Tim/eclipse-workspace/springMVC-mybatis-postgresql-fbcda0e11b1addcac43be8813e16b8b703022591/src/main/java/com/core/newbie/controller/UserController.java:[49,52] incompatible types: com.core.newbie.model.User cannot be converted to java.util.List<com.core.newbie.model.User>
  4. [ERROR] /C:/Users/Tim/eclipse-workspace/springMVC-mybatis-postgresql-fbcda0e11b1addcac43be8813e16b8b703022591/src/main/java/com/core/newbie/impl/UserServiceImpl.java:[29,8] com.core.newbie.impl.UserServiceImpl is not abstract and does not override abstract method getAll() in com.core.newbie.service.UserService
  5. [ERROR] /C:/Users/Tim/eclipse-workspace/springMVC-mybatis-postgresql-fbcda0e11b1addcac43be8813e16b8b703022591/src/main/java/com/core/newbie/impl/UserServiceImpl.java:[59,23] getAll() in com.core.newbie.impl.UserServiceImpl cannot implement getAll() in com.core.newbie.service.UserService
  6. return type java.util.List<com.core.newbie.model.User> is not compatible with com.core.newbie.model.User
  7. [ERROR] /C:/Users/Tim/eclipse-workspace/springMVC-mybatis-postgresql-fbcda0e11b1addcac43be8813e16b8b703022591/src/main/java/com/core/newbie/impl/UserServiceImpl.java:[57,5] method does not override or implement a method from a supertype
  8. [ERROR] /C:/Users/Tim/eclipse-workspace/springMVC-mybatis-postgresql-fbcda0e11b1addcac43be8813e16b8b703022591/src/main/java/com/core/newbie/impl/UserServiceImpl.java:[60,26] cannot find symbol
  9. symbol: method findAll()
  10. location: variable userMapper of type com.core.newbie.mapper.UserMapper
  11. [INFO] 5 errors
  12. [INFO] -------------------------------------------------------------
  13. [INFO] ------------------------------------------------------------------------
  14. [INFO] BUILD FAILURE
  15.  
  16. <?xml version="1.0" encoding="UTF-8" ?>
  17. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  18. <mapper namespace="com.core.newbie.mapper.UserMapper">
  19. <resultMap id="BaseResultMap" type="com.core.newbie.model.User">
  20. <id column="id" property="id" jdbcType="INTEGER"/>
  21. <result column="user_name" property="userName" jdbcType="VARCHAR"/>
  22. <result column="password" property="password" jdbcType="VARCHAR"/>
  23. <result column="age" property="age" jdbcType="INTEGER"/>
  24. </resultMap>
  25.  
  26. <sql id="Base_Column_List">
  27. id, user_name, password, age
  28. </sql>
  29.  
  30. <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
  31. select
  32. <include refid="Base_Column_List"/>
  33. from n_user
  34. where id = #{id,jdbcType=INTEGER}
  35. </select>
  36.  
  37. <select id="findAll" resultMap="BaseResultMap">
  38. select * from n_user
  39. </select>
  40.  
  41. <!--<select id="selectAllWithPagination" resultMap="BaseResultMap">
  42. select * from n_user
  43. </select>-->
  44.  
  45. <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
  46. delete from n_user
  47. where id = #{id,jdbcType=INTEGER}
  48. </delete>
  49.  
  50. <insert id="insert" parameterType="com.core.newbie.model.User">
  51. insert into n_user (id, user_name, password,
  52. age)
  53. values (#{id,jdbcType=INTEGER}, #{userName,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR},
  54. #{age,jdbcType=INTEGER})
  55. </insert>
  56.  
  57. <insert id="insertSelective" parameterType="com.core.newbie.model.User">
  58. insert into n_user
  59. <trim prefix="(" suffix=")" suffixOverrides=",">
  60. <if test="id != null">
  61. id,
  62. </if>
  63. <if test="userName != null">
  64. user_name,
  65. </if>
  66. <if test="password != null">
  67. password,
  68. </if>
  69. <if test="age != null">
  70. age,
  71. </if>
  72. </trim>
  73. <trim prefix="values (" suffix=")" suffixOverrides=",">
  74. <if test="id != null">
  75. #{id,jdbcType=INTEGER},
  76. </if>
  77. <if test="userName != null">
  78. #{userName,jdbcType=VARCHAR},
  79. </if>
  80. <if test="password != null">
  81. #{password,jdbcType=VARCHAR},
  82. </if>
  83. <if test="age != null">
  84. #{age,jdbcType=INTEGER},
  85. </if>
  86. </trim>
  87. </insert>
  88.  
  89. <update id="updateByPrimaryKeySelective" parameterType="com.core.newbie.model.User">
  90. update n_user
  91. <set>
  92. <if test="userName != null">
  93. user_name = #{userName,jdbcType=VARCHAR},
  94. </if>
  95. <if test="password != null">
  96. password = #{password,jdbcType=VARCHAR},
  97. </if>
  98. <if test="age != null">
  99. age = #{age,jdbcType=INTEGER},
  100. </if>
  101. </set>
  102. where id = #{id,jdbcType=INTEGER}
  103. </update>
  104.  
  105. <update id="updateByPrimaryKey" parameterType="com.core.newbie.model.User">
  106. update n_user
  107. set user_name = #{userName,jdbcType=VARCHAR},
  108. password = #{password,jdbcType=VARCHAR},
  109. age = #{age,jdbcType=INTEGER}
  110. where id = #{id,jdbcType=INTEGER}
  111. </update>
  112. </mapper>
  113.  
  114. package com.core.newbie.model;
  115.  
  116. import javax.persistence.*;
  117. import java.util.Set;
  118.  
  119. public class User {
  120.  
  121. private Integer id;
  122.  
  123. private String userName;
  124.  
  125. private String password;
  126.  
  127. private Integer age;
  128.  
  129. @ManyToMany
  130. @JoinTable(name = "user_roles", joinColumns = @JoinColumn(name = "user_id"),
  131. inverseJoinColumns = @JoinColumn(name = "role_id"))
  132. private Set<Role> roles;
  133.  
  134. public Integer getId() {
  135. return id;
  136. }
  137.  
  138. public void setId(final Integer id) {
  139. this.id = id;
  140. }
  141.  
  142. public String getUserName() {
  143. return userName;
  144. }
  145.  
  146. public void setUserName(final String userName) {
  147. this.userName = userName == null ? null : userName.trim();
  148. }
  149.  
  150. public String getPassword() {
  151. return password;
  152. }
  153.  
  154. public void setPassword(final String password) {
  155. this.password = password == null ? null : password.trim();
  156. }
  157.  
  158. public Integer getAge() {
  159. return age;
  160. }
  161.  
  162. public void setAge(final Integer age) {
  163. this.age = age;
  164. }
  165.  
  166. public Set<Role> getRoles() {
  167. return roles;
  168. }
  169.  
  170. public void setRoles(Set<Role> roles) {
  171. this.roles = roles;
  172. }
  173. }
  174.  
  175. package com.core.newbie.service;
  176.  
  177. import com.core.newbie.model.User;
  178.  
  179. public interface UserService {
  180. User getUserById(int userId);
  181.  
  182. // User findByUsername(String username);
  183.  
  184. void insetUser(User user);
  185.  
  186. User getAll();
  187. }
  188.  
  189. package com.core.newbie.impl;
  190.  
  191. import com.core.newbie.mapper.UserMapper;
  192. import com.core.newbie.model.User;
  193. import com.core.newbie.service.UserService;
  194.  
  195. import java.util.List;
  196.  
  197. import org.apache.ibatis.annotations.Select;
  198.  
  199. import org.springframework.beans.factory.annotation.Autowired;
  200. import org.springframework.stereotype.Service;
  201.  
  202. @Service("userService")
  203. public class UserServiceImpl implements UserService {
  204. @Autowired
  205. private UserMapper userMapper;
  206.  
  207. @Override
  208. public User getUserById(final int userId) {
  209. return userMapper.selectByPrimaryKey(userId);
  210. }
  211.  
  212. @Override
  213. public void insetUser(final User user) {
  214. userMapper.insert(user);
  215. }
  216.  
  217. @Override
  218. @Select("select * from n_user")
  219. public List<User> getAll() {
  220. return userMapper.findAll();
  221. }
  222. }
  223.  
  224. package com.core.newbie.controller;
  225.  
  226. import com.alibaba.fastjson.JSON;
  227. import com.core.newbie.model.User;
  228. import com.core.newbie.service.UserService;
  229. import org.apache.log4j.Logger;
  230. import org.springframework.beans.factory.annotation.Autowired;
  231. import org.springframework.stereotype.Controller;
  232. import org.springframework.ui.Model;
  233. import org.springframework.web.bind.annotation.RequestMapping;
  234.  
  235. import java.util.List;
  236.  
  237. import javax.servlet.http.HttpServletRequest;
  238.  
  239. @Controller
  240. @RequestMapping("/user")
  241. public class UserController {
  242. Logger logger = Logger.getLogger(UserController.class);
  243.  
  244. @Autowired
  245. private UserService userService;
  246.  
  247. @RequestMapping("/showUser")
  248. public String showUser(final HttpServletRequest request, final Model model)
  249. {
  250. final int userId = Integer.parseInt(request.getParameter("id"));
  251. final User user = userService.getUserById(userId);
  252. model.addAttribute("user", user);
  253. logger.debug("running in UserController.java -> showUser()");
  254. logger.info(JSON.toJSON(request.getRequestURI()));
  255. logger.info(JSON.toJSON(user));
  256. return "/user/showUser.jsp";
  257. }
  258.  
  259. @RequestMapping("/users")
  260. public String users() {
  261. final List<User> users = userService.getAll();
  262. logger.debug("running in UserController.java -> users()");
  263. logger.info(JSON.toJSON(users));
  264. return "/user/users.jsp";
  265. }
  266. }
Add Comment
Please, Sign In to add comment