发表于: 2020-05-22 21:12:16

1 1335


今天完成的事情:增删改查 在Linux上部署服务器

一、在孙师兄的帮助下终于完成了增删改查

写好了一个查询功能的接口,运行之后却报错

然后查看详细内容说什么有两个Bean,但是我的代码明明只有一个


然后搞了好长时间,原来是IDEA抽风了, ISstudentSerivce  这个接口名称我改了很多次,导致他没有及时的收拾垃圾,然后手动 maven clean 就好了

@Controller
@RequestMapping(value = "/student")
public class StudentController {
//导入日志
//    private static Logger logger = Logger.getLogger(StudentController.class);

   @Resource(name = "studentService")
private IStudentService iStudentService;

(轻描淡写的描述问题然后优雅的解决问题,殊不知背后被他折磨了多久)

在Spring配置文件中需要加上这样的配置

<!--強制注入-->
   <bean id="studentService" class="com.service.impl.IStudentServiceImpl">
       <property name="iStudentMapper" ref="IStudentMapper"/>

强制注入 需要在业务层 setter and getter

//使用強制注入需要 getter and setter
   public IStudentMapper getiStudentMapper() {
return iStudentMapper;
   }

public void setiStudentMapper(IStudentMapper iStudentMapper) {
this.iStudentMapper = iStudentMapper;
   }

通过ID查找

浏览器只能获取信息 增删改操作只能从Postman中进行

结果

删除

结果

更改

结果

模糊查询

查询全部

model.addattribute()的作用

1.往前台传数据,可以传对象,可以传List,通过el表达式 ${}可以获取到

2.@ModelAttribute("model")   注解

二、在服务器上部署Resin tomcat

记录一下端口

Resin    8080

tomcat  8082

尝试在服务器上跑代码没有成功,好像是war包打的有问题,通过Maven package 打的包 跟通过 git 打的包不一样...emmm 明天研究下

明天的任务:在服务器上成功跑代码


返回列表 返回列表
评论

    分享到