服务器部署springboot项目怎么导入数据库(部署springboot项目到服务器上)

服务器部署springboot项目怎么导入数据库(部署springboot项目到服务器上)1 http start spring io nbsp nbsp nbsp nbsp A Artifact 中输入 spring boot sample mysql nbsp nbsp nbsp nbsp B 勾选 Web 下的 web nbsp nbsp nbsp amp

大家好,我是讯享网,很高兴认识大家。



1、http://start.spring.io/

     A、Artifact中输入spring-boot-sample-mysql

     B、勾选Web下的web

     C、勾选SQL下的JPA MYSQL

2、Eclips中导入工程spring-boot-sample-mysql

     A、解压快捷工程spring-boot-sample-mysql到某文件夹

     B、eclips中file->import->Import Existing Maven Projects–>Select Maven projects–>finish导入工程

3、导入工程。pom.xml内容参考上一篇文章《SpringBoot实战(一):HelloWorld》

4、引入LOG机制,在src/main/resources文件夹下新建logback.xml,配置为

<strong>[html]</strong>&nbsp; 
view plain 
&nbsp;copy 
</p><p> <br></p><p>     <br></p><p>  <br></p><ol start="1"></ol><div></div><p> <br></p><p> 在工程所在的根目录找到log文件夹,进去,再打开base.log,入下图</p><p> <br></p><p style="text-align:center;"><img    src='https://s2.51cto.com/images/blog/202403/26112810_660240ca3648335558.jpg?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_30,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=/resize,m_fixed,w_1184' alt='springboot项目导入jar springboot项目导入MySQL_mysql'  style="width: 1376px; visibility: visible;"></p><p> 注:文件夹和日志文件的名称,都是在配置文件logback.xml中设置的</p><p> <br></p><p> <br></p><p>5、启动工程,通过浏览器查看正确性</p><p>http://localhost:8080/</p><p> 1、在包com.enn下建立entity包,新建UserInfo类。 <br></p><p> entity类存储物理班的信息。 <br></p><div></div><p> <br></p><p> <br></p><p>2、在包com.enn下建立dao包,新建UserInfoMapper抽象类和UserInfoImpl实现类。dao层负责与数据库交互。</p><p><br></p><div></div><div></div><p>3、 <br></p><p> 在包com.enn下建立service包,新建UserService类。service层进行业务逻辑处理。 

讯享网

4、在包com.enn下建立controller包,新建UserController类。controller类来获取前端传来的参数信息。

controller类来获取前端传来的参数信息,这部分我们之前已经说过,这里不再赘述。然后将参数传入service层进行业务逻辑处理,之后由dao层负责与数据库交互。是的,这套路就是我们平时在是集开发工作中会用到的。

6、运行测试

A、先保存数据

http://localhost:8080/save?id=aa&&address=北京 http://localhost:8080/save?name=ab&&address=北京&&age=2
http://localhost:8080/save?name=cq1&&address=重庆&&age=50
http://localhost:8080/save?name=cq2&&address=重庆&&age=51

B、查询q1

http://localhost:8080/select?address=北京

C、查询q2

http://localhost:8080/q2?address=北京&&name=aa


讯享网

D、查询q3

http://localhost:8080/q3?address=北京&&name=aa

E、排序

http://localhost:8080/sort

F、分页

http://localhost:8080/page

运用hibernate访问mysql,基本也是老技术,只是用JPA简化了dao层代码,对于业务对象基本没有变化。

我报错是因为pom.xml引用不对造成的,通过官网下载示例构建的工程,报错消失。

3、1063 Incorrect column specifier for column ‘id’

插入数据要求自增序列,修改mysql中的表即可。



1、http://start.spring.io/

&nbsp;&nbsp;&nbsp;&nbsp; A、Artifact中输入spring-boot-sample-mysql

&nbsp;&nbsp;&nbsp;&nbsp; B、勾选Web下的web

&nbsp;&nbsp;&nbsp;&nbsp; C、勾选SQL下的JPA MYSQL

2、Eclips中导入工程spring-boot-sample-mysql

&nbsp;&nbsp;&nbsp;&nbsp; A、解压快捷工程spring-boot-sample-mysql到某文件夹

&nbsp;&nbsp;&nbsp;&nbsp; B、eclips中file-&gt;import-&gt;Import Existing Maven Projects–&gt;Select Maven projects–&gt;finish导入工程

3、导入工程。pom.xml内容参考上一篇文章《SpringBoot实战(一):HelloWorld》

4、引入LOG机制,在src/main/resources文件夹下新建logback.xml,配置为

讯享网<strong>[html]</strong>&nbsp; 
view plain 
&nbsp;copy 
</p><p> <br></p><p>     <br></p><p>  <br></p><ol start="1"><li></li></ol><div></div>
小讯
上一篇 2025-05-05 23:09
下一篇 2025-04-22 10:39

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/168643.html