今天一起来把之前文章提到的博客系统的框架结构搭建出来。想做这个项目的自己动手练练。
这个项目用mavan来管理的,新建一个maven项目。建好以后会生生一个pom.xml文件,先从它开始配置。
一:【pom.xml配置】在此标签加入如下配置;集成springmvc,spring,mybatis的配置与jar包加载。另外还有就是项目中所有用到的其他集成框架的配置。
javax.servletjavax.servlet-api3.1.0javax.servlet.jspjavax.servlet.jsp-api2.3.1javax.servletjstl1.2org.springframework spring-core 4.1.7.RELEASEorg.springframework spring-beans 4.1.7.RELEASEorg.springframework spring-tx 4.1.7.RELEASEorg.springframework spring-context 4.1.7.RELEASEorg.springframework spring-context-support 4.1.7.RELEASEorg.springframeworkspring-web4.1.7.RELEASEorg.springframeworkspring-webmvc4.1.7.RELEASEorg.springframeworkspring-aop4.1.7.RELEASEorg.springframeworkspring-aspects4.1.7.RELEASEorg.springframeworkspring-jdbc4.1.7.RELEASEorg.mybatismybatis-spring1.2.3log4jlog4j1.2.17org.slf4jslf4j-log4j121.7.12org.mybatismybatis3.3.0mysqlmysql-connector-java5.1.37org.apache.shiroshiro-core1.2.4org.apache.shiroshiro-web1.2.4org.apache.shiroshiro-spring1.2.4commons-fileuploadcommons-fileupload1.3.1commons-codeccommons-codec1.10commons-langcommons-lang2.5commons-beanutilscommons-beanutils1.8.0commons-collectionscommons-collections3.2.1commons-loggingcommons-logging1.1.1net.sf.ezmorphezmorph1.0.6org.apache.lucenelucene-core5.3.1org.apache.lucenelucene-analyzers-common5.3.1org.apache.lucenelucene-analyzers-smartcn5.3.1org.apache.lucenelucene-queryparser5.3.1org.apache.lucenelucene-highlighter5.3.1com.alibabadruid1.0.16
二:【springmvc进行配置】
配置spring-mvc.xml;
三:【spring配置】
配置:applicationContext.xml;
/login=anon/admin/**=authc
四:【mybatis配置】
配置mybatis-config.xml;
这里我就是把实体都映射到这里了,就不需要加乱七八糟的前缀了。直接用类名就行了。
五:封包:
创建用户实体类:
创建实体类Dao层接口;具体实现交给mybatis;
然后就开始进行创建并配置BloggerMapper.xml;
这里我就主要定义了一个结果集,后续自己开发时候select,delete等等就在这里面进行定义。
创建service层:
主要是事物层的逻辑实现。和dao层一样,创建service层接口以及它的实现类;
直接用注解方式:@Service("bloggerService");
在进行创建controller层;用于访问前台页面;
@Controller@RequestMapping("/blogger")//映射路径public class BloggerController {@Resourceprivate BloggerService bloggerService;//注入}
六:【自定义realm】
这个设计就是,验证当前登录的用户;
* 验证当前登录的用户
*/
@Overrideprotected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {// TODO Auto-generated method stubreturn null;}}
七:【web.xml配置】
index.jspshiroFilterorg.springframework.web.filter.DelegatingFilterProxytargetFilterLifecycletrueshiroFilter/*contextConfigLocationclasspath:applicationContext.xmlencodingFilterorg.springframework.web.filter.CharacterEncodingFiltertrueencodingUTF-8encodingFilter/*org.springframework.web.context.ContextLoaderListenerspringMVCorg.springframework.web.servlet.DispatcherServletcontextConfigLocationclasspath:spring-mvc.xml1truespringMVC*.dospringMVC*.html
ok;随便写个jsp发布请求一下,这个框架就完事;大家好好配置练习一下;
有不懂和疑问随时问我;
项目jar包获取方法:点赞+关注+私信问我要就行了