ssm+RESTful bbs项目后端主要设计

匿名 (未验证) 提交于 2019-12-02 21:35:18

С̸

帖主妥妥的一名"中"白了哈哈哈。软工的大三狗了,也即将找工作,怀着丝丝忐忑接受社会的安排。这是第一次写博客(/汗颜),其实之前在学习探索过程中,走了不少弯路,爬过不少坑。真的挺感谢一路上的前辈们的博客也好,随笔也好,哪怕是评论,或多或少解决了一些问题。我感觉学技术的过程中,记录下自己解决问题的过程、经验,如果可以的话能分享,其实也挺好。希望能从“中白”变“大白”,再到佬行列哈哈。

简介:

https://blog.csdn.net/qq_21383435/article/details/80032375githubhttps://github.com/isMaxaaa/bbs


步骤:

1.数据库设计:

 1 CREATE TABLE user (  2   user_id int(11) NOT NULL AUTO_INCREMENT,  3   user_name varchar(50)  DEFAULT NULL,  4   email varchar(50) DEFAULT NULL,  5   replys int(11) DEFAULT NULL,  6   topics int(11) DEFAULT NULL,  7   create_time timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,  8   praises int(11) DEFAULT NULL,  9   PRIMARY KEY (user_id) 10 ) 11  12 CREATE TABLE post ( 13   topic_id int(11) NOT NULL AUTO_INCREMENT, 14   user_id int(11) NOT NULL, 15   title varchar(100) NOT NULL, 16   content` varchar(20140) NOT NULL, 17   create_time timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 18   lastset_time timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON          19                                                         UPDATE CURRENT_TIMESTAMP, 20   PRIMARY KEY (topic_id), 21   FOREIGN KEY (use_id) REFERENCES user (user_id) 22 ) 23  24 CREATE TABLE comment ( 25   comment_id int(11) NOT NULL AUTO_INCREMENT, 26   topic_id int(11) NOT NULL, 27   user_id  int(11) NOT NULL, 28   comment_time timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 29   content varchar(200) NOT NULL, 30   PRIMARY KEY (comment_id), 31   FOREIGN KEY (use_id)   REFERENCES user (user_id), 32   FOREIGN KEY (topic_id) REFERENCES post(topic_id) 33 ) 34       35 CREATE TABLE reply ( 36   reply_id int(11) NOT NULL AUTO_INCREMENT, 37   comment_id int(11) NOT NULL, 38   reply_user int(11) NOT NULL, 39   reply_time timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 40   content varchar(200) NOT NULL, 41   PRIMARY KEY (reply_id), 42   FOREIGN KEY (comment_id) REFERENCES comment (comment_id) 43   FOREIGN KEY (reply_user) REFERENCES user (user_id) 44 ) 45  46 CREATE TABLE praise ( 47   id int(11) NOT NULL AUTO_INCREMENT, 48   topic_id int(11) NOT NULL, 49   user_id int(11) NOT NULL, 50   PRIMARY KEY (`id`), 51   FOREIGN KEY (use_id) REFERENCES user (user_id) 52   FOREIGN KEY (topic_id) REFERENCES post (topic_id) 53 )
View Code

https://www.cnblogs.com/xiohao/archive/2013/06/28/3160265.html

 1  comment :  2  alter table comment add constraint comment_cons  3  foreign key(topic_id)  4  references post(topic_id)  5  on delete set null;  6    7  reply:  8  alter table reply add constraint reply_cons  9  foreign key(comment_id) 10  references comment(comment_id) 11  on delete set null; 12  13  praise: 14  alter table praise add contraint praise_cons 15  foreign key(topic_id) 16  references post(topic_id) 17  on delete set null;
View Code

2.resful设计:

3.idea创建项目:

创建完整后:

4.配置文件的说明:

在main下新建一个resources资源,这里面主要是放spring的mvc的相关核心配置文件的。mapper是dao层的的映射,里面主要是每个dao相关的sql语句。spring里面放的是dao层、service、controller层的spring配置,如置数据库连接池,扫描包的注解类型,servlet的配置等等。在源码里有相关配置的简单的注释。


5.出现的问题及解决:

1.在配置jdbc.properties时,什么driver、url、username、password都没问题,但在spring-dao.xml中配置数据库的连接池,使用数据库的相关参数也就是jdbc.proerties,最后测试时总体是连接超时拒绝。把相关的参数直接写在value值时,又没问题。。。最后整了半天,总算查到了原因:spring4.0 在引入外部property文件需要使用下面的格式。3.0可以直接使用第二种。

<!-- 引入jdbc配置文件 --> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <!--要是有多个配置文件,只需在这里继续添加即可 --> <value>classpath:properties/*.properties</value> </list> </property> </bean><context:property-placeholder location="classpath:jdbc.properties" />

2.还有一个是提示,mybatis.xml的什么哪个setting出错,最后查到只要将settings的那个设置删掉就行。

3.在pom.xml中添加资源文件路径配置,没添加在加载配置文件可能会提示路径找不到。

  <resources>     <resource>       <directory>src/main/resources</directory>       <includes>         <include>**/*.*</include>       </includes>       <filtering>true</filtering>     </resource>   </resources>

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!