Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [ERROR] COMPILATION ERROR :
- [INFO] -------------------------------------------------------------
- [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>
- [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
- [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
- return type java.util.List<com.core.newbie.model.User> is not compatible with com.core.newbie.model.User
- [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
- [ERROR] /C:/Users/Tim/eclipse-workspace/springMVC-mybatis-postgresql-fbcda0e11b1addcac43be8813e16b8b703022591/src/main/java/com/core/newbie/impl/UserServiceImpl.java:[60,26] cannot find symbol
- symbol: method findAll()
- location: variable userMapper of type com.core.newbie.mapper.UserMapper
- [INFO] 5 errors
- [INFO] -------------------------------------------------------------
- [INFO] ------------------------------------------------------------------------
- [INFO] BUILD FAILURE
- <?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="com.core.newbie.mapper.UserMapper">
- <resultMap id="BaseResultMap" type="com.core.newbie.model.User">
- <id column="id" property="id" jdbcType="INTEGER"/>
- <result column="user_name" property="userName" jdbcType="VARCHAR"/>
- <result column="password" property="password" jdbcType="VARCHAR"/>
- <result column="age" property="age" jdbcType="INTEGER"/>
- </resultMap>
- <sql id="Base_Column_List">
- id, user_name, password, age
- </sql>
- <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
- select
- <include refid="Base_Column_List"/>
- from n_user
- where id = #{id,jdbcType=INTEGER}
- </select>
- <select id="findAll" resultMap="BaseResultMap">
- select * from n_user
- </select>
- <!--<select id="selectAllWithPagination" resultMap="BaseResultMap">
- select * from n_user
- </select>-->
- <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
- delete from n_user
- where id = #{id,jdbcType=INTEGER}
- </delete>
- <insert id="insert" parameterType="com.core.newbie.model.User">
- insert into n_user (id, user_name, password,
- age)
- values (#{id,jdbcType=INTEGER}, #{userName,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR},
- #{age,jdbcType=INTEGER})
- </insert>
- <insert id="insertSelective" parameterType="com.core.newbie.model.User">
- insert into n_user
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="id != null">
- id,
- </if>
- <if test="userName != null">
- user_name,
- </if>
- <if test="password != null">
- password,
- </if>
- <if test="age != null">
- age,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="id != null">
- #{id,jdbcType=INTEGER},
- </if>
- <if test="userName != null">
- #{userName,jdbcType=VARCHAR},
- </if>
- <if test="password != null">
- #{password,jdbcType=VARCHAR},
- </if>
- <if test="age != null">
- #{age,jdbcType=INTEGER},
- </if>
- </trim>
- </insert>
- <update id="updateByPrimaryKeySelective" parameterType="com.core.newbie.model.User">
- update n_user
- <set>
- <if test="userName != null">
- user_name = #{userName,jdbcType=VARCHAR},
- </if>
- <if test="password != null">
- password = #{password,jdbcType=VARCHAR},
- </if>
- <if test="age != null">
- age = #{age,jdbcType=INTEGER},
- </if>
- </set>
- where id = #{id,jdbcType=INTEGER}
- </update>
- <update id="updateByPrimaryKey" parameterType="com.core.newbie.model.User">
- update n_user
- set user_name = #{userName,jdbcType=VARCHAR},
- password = #{password,jdbcType=VARCHAR},
- age = #{age,jdbcType=INTEGER}
- where id = #{id,jdbcType=INTEGER}
- </update>
- </mapper>
- package com.core.newbie.model;
- import javax.persistence.*;
- import java.util.Set;
- public class User {
- private Integer id;
- private String userName;
- private String password;
- private Integer age;
- @ManyToMany
- @JoinTable(name = "user_roles", joinColumns = @JoinColumn(name = "user_id"),
- inverseJoinColumns = @JoinColumn(name = "role_id"))
- private Set<Role> roles;
- public Integer getId() {
- return id;
- }
- public void setId(final Integer id) {
- this.id = id;
- }
- public String getUserName() {
- return userName;
- }
- public void setUserName(final String userName) {
- this.userName = userName == null ? null : userName.trim();
- }
- public String getPassword() {
- return password;
- }
- public void setPassword(final String password) {
- this.password = password == null ? null : password.trim();
- }
- public Integer getAge() {
- return age;
- }
- public void setAge(final Integer age) {
- this.age = age;
- }
- public Set<Role> getRoles() {
- return roles;
- }
- public void setRoles(Set<Role> roles) {
- this.roles = roles;
- }
- }
- package com.core.newbie.service;
- import com.core.newbie.model.User;
- public interface UserService {
- User getUserById(int userId);
- // User findByUsername(String username);
- void insetUser(User user);
- User getAll();
- }
- package com.core.newbie.impl;
- import com.core.newbie.mapper.UserMapper;
- import com.core.newbie.model.User;
- import com.core.newbie.service.UserService;
- import java.util.List;
- import org.apache.ibatis.annotations.Select;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- @Service("userService")
- public class UserServiceImpl implements UserService {
- @Autowired
- private UserMapper userMapper;
- @Override
- public User getUserById(final int userId) {
- return userMapper.selectByPrimaryKey(userId);
- }
- @Override
- public void insetUser(final User user) {
- userMapper.insert(user);
- }
- @Override
- @Select("select * from n_user")
- public List<User> getAll() {
- return userMapper.findAll();
- }
- }
- package com.core.newbie.controller;
- import com.alibaba.fastjson.JSON;
- import com.core.newbie.model.User;
- import com.core.newbie.service.UserService;
- import org.apache.log4j.Logger;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- import org.springframework.ui.Model;
- import org.springframework.web.bind.annotation.RequestMapping;
- import java.util.List;
- import javax.servlet.http.HttpServletRequest;
- @Controller
- @RequestMapping("/user")
- public class UserController {
- Logger logger = Logger.getLogger(UserController.class);
- @Autowired
- private UserService userService;
- @RequestMapping("/showUser")
- public String showUser(final HttpServletRequest request, final Model model)
- {
- final int userId = Integer.parseInt(request.getParameter("id"));
- final User user = userService.getUserById(userId);
- model.addAttribute("user", user);
- logger.debug("running in UserController.java -> showUser()");
- logger.info(JSON.toJSON(request.getRequestURI()));
- logger.info(JSON.toJSON(user));
- return "/user/showUser.jsp";
- }
- @RequestMapping("/users")
- public String users() {
- final List<User> users = userService.getAll();
- logger.debug("running in UserController.java -> users()");
- logger.info(JSON.toJSON(users));
- return "/user/users.jsp";
- }
- }
Add Comment
Please, Sign In to add comment