前言:
最近没什么事做,搭个框架写成博客记录下来,拉通一下之前所学知识.
话不多说,我们直接步入正题。
准备工作:
1/安装并配置java运行环境
2/数据库的安装配置(Mysql)
3/安装并配置服务器(Tomcat)
4/Maven
5/ IntelliJIDEA的安装配置(本人使用的主要软件是IntelliJIDEA,没用eclipse什么的)
6/ 使用IntelliJIDEA创建一个web app项目。
貌似就这些了吧
导包
不同于以往的导包,由于我们创建的是maven的webapp项目,所以现在只需配置下pomxml这个配置文件,系统会自动到maven的中央仓库去下载相应的包.
本人的pom.xml配置文件如下(都写有说明的哈):
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://.ssh.service.TestService;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;import org.springframework.web.bind.annotation.ResponseBody;/** * Created by XRog * On 2/1/2017.12:36 AM */@Controllerpublic class MainController { @Autowired private PersonService personService; @RequestMapping(value = "savePerson", method = RequestMethod.GET) @ResponseBody public String savePerson(){ personService.savePerson(); return "success!"; }}OK,编写完毕,我们重启下服务器然后测试:
我们在看下数据库,跟我们插入的数据对比下
OK,测试完毕,十分成功
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持!
热门文章