X Tutup
Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.md

APIJSON后端部署 - Java

1.下载后解压APIJSON工程

打开APIJSON的GitHub主页 > Clone or download > Download ZIP > 解压到一个路径并记住这个路径。


2.用Eclipse for JavaEE或IntellIJ IDEA Ultimate运行后端工程

如果以上编辑器一个都没安装,运行前先下载安装一个。
我的配置是Windows 7 + JDK 1.7.0_71 + Eclipse 4.6.1 + IntellIJ 2016.3 和 OSX EI Capitan + JDK 1.8.0_91 + Eclipse 4.6.1 + IntellIJ 2016.2.5

Eclipse for JavaEE

1)打开
File > Import > Maven > Existing Maven Projects > Next > Browse
> 选择刚才解压路径下的APIJSON-Master/APIJSON-Java-Server/APIJSON-Eclipse
> 勾选 APIJSONDemo 和 APIJSONLibrary > Finish

如果apijson-library有错误,一般是JDK版本过低,可以:
右键apijson-library > Properties > Java Compiler > 取消选择Use compliance from ... > Complier compliance level选1.7以上的 > OK
2)Demo依赖Library
右键apijson-demo > Properties > Java Build Path > Projects > Add > 选择apijson-library > OK > OK
3)配置(如果完成下方步骤4,导入APIJSON的表,则可跳过)
打开 apijson.demo.server.DemoSQLConfig 类,编辑 getDBUri,getDBAccount,getDBPassword,getSchema 的返回值为你自己数据库的配置。
4)运行
Run > Run As > Java Application > 选择APIJSONApplication > OK

IntellIJ IDEA Ultimate

1)打开
Open > 选择刚才解压路径下的APIJSON-Master/APIJSON-Java-Server/APIJSON-Idea/APIJSONDemo > OK

如果有错误,一般是Idea没有给Module分配JDK,
在Project Structure最下方的Problems会有project SDK is not defined报错,可以:
File > Project Structure > Project > Project SDK 选已安装的JDK
如果没有,则继续
New... > JDK > 选择JDK的安装路径 > Open
最后在底部
Apply 或 OK
2)Demo依赖Library
File > New > Module from Existing Sources > 选和APIJSONDemo同目录下的APIJSONLibrary > Open
> 右键APIJSONDemo > Open Module Settings > Modules > apijson-demo > Dependencies
> 左下方 + > Module Dependency > 选择apijson-library > OK > OK
3)配置(如果完成下方步骤4,导入APIJSON的表,则可跳过)
打开 apijson.demo.server.DemoSQLConfig 类,编辑 getDBUri,getDBAccount,getDBPassword,getSchema 的返回值为你自己数据库的配置。
4)运行
Run > Run APIJSONApplication

如果弹窗里只有Edit Configurations...这个选项,则点进去,然后
+ > Application > Main class 选apijson.demo.server.APIJSONApplication
> Use class path of module 选apijson-demo
> 最后在底部 Run

运行后会出现 APIJSON的测试日志,最后显示 "APIJSON已启动" ,说明已启动完成。

如果是Address already in use,说明8080端口被占用,
可以关闭占用这个端口的程序(可能就是已运行的APIJSON工程)
或者 改下APIJSON工程的端口号,参考SpringBoot改端口
其它问题请谷歌或百度。


3.测试连接

在浏览器输入 http://localhost:8080/get/{}
如果出现

{
  "code": 200,
  "msg": "success"
}

则说明已连接上。

如果是404 Not Found,请把防火墙关闭,以便外网能够访问你的电脑或服务器。
其它问题请谷歌或百度。


4.导入表文件到数据库

可以先跳过,用Table, Column或者其它 你自己数据库中已有的表 来测试。

后端需要MySQL Server和MySQLWorkbench,没有安装的都先下载安装一个。
我的配置是Windows 7 + MySQL Community Server 5.7.16 + MySQLWorkbench 6.3.7 和 OSX EI Capitan + MySQL Community Server 5.7.16 + MySQLWorkbench 6.3.8,其中系统和软件都是64位的。

启动MySQLWorkbench > 进入一个Connection > 点击Server菜单 > Data Import > 选择刚才解压路径下的APIJSON-Master/table > Start Import > 刷新SCHEMAS, 左下方sys/tables会出现添加的table。


5.测试接口

直接使用 APIJSON在线工具 或 下载主页提供的 客户端App


X Tutup