美文网首页
j2ee开发日记(2)搭建springboot + vue项目(

j2ee开发日记(2)搭建springboot + vue项目(

作者: 皓月__ | 来源:发表于2018-10-26 14:25 被阅读0次

    en,搭建一个springboot项目,只需要20秒。

    怎么做呢?

    1  点击这个https://start.spring.io/

    2  在搜索框里输入 web ,然后选择第一个

    3  最后小手一抖,点一下 Generate Project 按钮,解压demo.zip,就完成了

    这里有视频为证:https://pan.baidu.com/s/1JcgEYjnPRc8pB7BNNqstow


    可是呢,这就是个展示的例子,实际开发没这么快,也没这么简单。

    下面说说真正开发要怎么搭建springboot项目:

    有两个选择:

    1  用git

    2  下载zip

    先说简单的,git

    命令如下:

    git clone https://github.com/moonnow/pro-rely.git

    git clone https://github.com/moonnow/tool.git

    git clone https://github.com/moonnow/test.git

    git clone https://github.com/moonnow/pro.git

    git clone https://github.com/moonnow/code-plugin.git

    git clone https://github.com/moonnow/vuepro.git

    直接复制就可以了。


    下载zip,网址如下:

    https://github.com/moonnow/pro-rely

    https://github.com/moonnow/tool

    https://github.com/moonnow/test

    https://github.com/moonnow/pro

    https://github.com/moonnow/code-plugin

    https://github.com/moonnow/vuepro


    文件下载完成,接下来就是核心内容了

    搭项目并运行

    用 maven 搭建 springboot 项目,我把开发常用的jar包引用都写好了,直接用就可以了,把下载到电脑的文件解压,需要改一下文件夹名,去掉“-master”。git克隆的不需要改名。像下面图片就行了。

    用eclipse导入maven项目,除了vuepro之外的文件夹都导入。

    现在项目就搭建好了

    想要马上能用,能看到效果,需要3步:

    1   保证mysql数据库能用

    2   配置数据库连接

    3   启动

    到这后台服务就完成了,能看到的效果呢,只有启动日志。

    想看到页面需要做两步:

    vuepro目录下运行命令:npm run dev

    启动项目就好了


    接下来呢请求会报错,原因是跨域。

    解决这个要用到 nginx

    修改配置文件

    mac nginx 配置文件路径:/usr/local/etc/nginx

    配置文件地址:https://github.com/moonnow/j2ee-developmentdiary/blob/master/j2ee%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA/08-nginx/nginx.conf

    然后启动 nginx

    命令:sudo nginx

    浏览器打开localhost:9400

    到这就能看到页面了


    结语

    前后台分离,后台服务项目用maven搭建springboot项目,前台用vue写,框架用iview admin,解决跨域问题用 nginx。

    相关文章

      网友评论

          本文标题:j2ee开发日记(2)搭建springboot + vue项目(

          本文链接:https://www.haomeiwen.com/subject/ccfktqtx.html