|
| 1 | +## <h2 id="2">2.Server-side deployment<h2/> |
| 2 | + |
| 3 | +You can use either Eclipse for JavaEE or IntelllJ IDEA Ultimate to make installation. For both, first download the project and save it to a path. |
| 4 | + |
| 5 | +### <h3 id="2.1">2.1 Installing with Eclipse<h3/> |
| 6 | + |
| 7 | +#### <h4 id="2.1.1">2.1.1 prerequisites<h4/> |
| 8 | + |
| 9 | +Java Development Kit(JDK): 1.8 or above |
| 10 | +[MAVEN](https://maven.apache.org/download.cgi): 3.0 or above |
| 11 | +Mysql / Oracle |
| 12 | +[Eclipse Java EE IDE](https://www.eclipse.org/downloads/)for Web Developers.Version: Mars.1 Release (4.5.1) |
| 13 | + |
| 14 | +#### <h4 id="2.1.2">2.1.2 Opening the project with Eclipse<h4/> |
| 15 | + |
| 16 | +Open Eclipse> *File > Import > Maven > Existing Maven Projects > Next > Browse > Select the path of the project you saved / APIJSON-Java-Server / APIJSONBoot > check pom.xml...apijson-demo > Finish* |
| 17 | + |
| 18 | +#### <h4 id="2.1.3">2.1.3 Preparing the library used in demo<h4/> |
| 19 | + |
| 20 | +In the menu at the right, click libs, right click apijson-orm.jar,click add as library. Apply the same to the rest *.jar* files in libs. |
| 21 | + |
| 22 | +#### <h4 id="2.1.4">2.1.4 Configuration<h4/> |
| 23 | + |
| 24 | +Open apijson.demo.server.DemoSQLConfig. In line 40-61, change return values of `getDBUri`,`getDBAccount`,`getDBPassword`,`getSchema` to your own database.<br/> |
| 25 | + |
| 26 | +```java |
| 27 | + static { |
| 28 | + DEFAULT_DATABASE = DATABASE_MYSQL; // TODO |
| 29 | + DEFAULT_SCHEMA = "sys"; // TODO defaults: MySQL: sys, PostgreSQL: public, SQL Server: dbo, Oracle: |
| 30 | + } |
| 31 | + |
| 32 | + @Override |
| 33 | + public String getDBVersion() { |
| 34 | + return "5.7.22"; // "8.0.11"; // TODO |
| 35 | + } |
| 36 | + |
| 37 | + @JSONField(serialize = false) |
| 38 | + @Override |
| 39 | + public String getDBUri() { |
| 40 | + // add userSSL=false for MySQL 8.0+ return "jdbc:mysql://localhost:3306?userSSL=false&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=UTF-8"; |
| 41 | + // for MySQL not greater than 5.7 |
| 42 | + return "jdbc:mysql://localhost:3306?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=UTF-8"; // TODO TiDB can be used as MySQL, its defaut port is 4000 |
| 43 | + } |
| 44 | + |
| 45 | + @JSONField(serialize = false) |
| 46 | + @Override |
| 47 | + public String getDBAccount() { |
| 48 | + return "root"; // TODO |
| 49 | + } |
| 50 | + |
| 51 | + @JSONField(serialize = false) |
| 52 | + @Override |
| 53 | + public String getDBPassword() { |
| 54 | + return "apijson"; // TODO TiDB can be used as MySQL, its defaut password is an empty string "" |
| 55 | + } |
| 56 | +``` |
| 57 | + |
| 58 | +**Note**: Instead of this step, you can also [import your database](#2.2). |
| 59 | + |
| 60 | +#### <h4 id="2.1.5">2.1.5 Running the application<h4/> |
| 61 | + |
| 62 | +In Eclipse, in the menu on the top, click *Run>Run As>Java Application>choose APIJSONApplication>OK* |
| 63 | + |
| 64 | +### <h3 id="2.2">2.2 Import MySQL table files<h3/> |
| 65 | + |
| 66 | +This Server project needs [MySQL Server](https://dev.mysql.com/downloads/mysql/) and [MySQLWorkbench](https://www.mysql.com/products/workbench/). Please make sure that both of them are installed.<br /> |
| 67 | + |
| 68 | +My config is Windows 7 + MySQL Community Server 5.7.16 + MySQLWorkbench 6.3.7 and OSX EI Capitan + MySQL Community Server 5.7.16 + MySQLWorkbench 6.3.8. Systems and softwares are all 64 bit. |
| 69 | + |
| 70 | +Start *MySQLWorkbench > Enter a connection > Click Server menu > Data Import > Select the path of your .sql file > Start Import > Refresh SCHEMAS*. Now you should see tables are added successfully. |
| 71 | + |
| 72 | +### <h3 id="2.3">2.3 Installing with IntellIJ IDEA Ultimate<h3/> |
| 73 | + |
| 74 | +#### <h4 id="2.3.1">2.3.1 Opening the project<h4/> |
| 75 | + |
| 76 | +*Open > Select the path of the project/APIJSON-Java-Server/APIJSONBoot > OK* |
| 77 | + |
| 78 | +#### <h4 id="2.3.2">2.3.2 Preparing the library used in demo<h4/> |
| 79 | + |
| 80 | +In libs, right-click *apijson-orm.jar >Add as Library>OK*. Apply this to all *.jar* files in libs. |
| 81 | + |
| 82 | +#### <h4 id="2.3.3">2.3.3 Running the application<h4/> |
| 83 | + |
| 84 | +In the menu on the top: *Run > Run > Edit Configurations > + > Application > Configuration*<br /> |
| 85 | +In *Main class* , choose *APIJSONApplication*;<br /> |
| 86 | +In *Use classpath of module* , choose *apijson-demo*.<br /> |
| 87 | +Click *Run* in the bottom. |
| 88 | + |
| 89 | +**Note**: After running, you should see APIJSON test logs and in the last, it would show ‘APIJSON已启动’. If it shows ‘address already in use’, that means port 8080 has been used . You need tochange the port. See [how to change ports for a Spring Boot Application.](https://stackoverflow.com/questions/21083170/how-to-configure-port-for-a-spring-boot-application) |
0 commit comments