File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed
APIJSON-Java-Server/APIJSONDemo/src/main/java/apijson/demo/server Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change 1616
1717import org .springframework .boot .SpringApplication ;
1818import org .springframework .boot .autoconfigure .SpringBootApplication ;
19+ import org .springframework .boot .context .embedded .ConfigurableEmbeddedServletContainer ;
20+ import org .springframework .boot .context .embedded .EmbeddedServletContainerCustomizer ;
1921import org .springframework .context .annotation .Bean ;
22+ import org .springframework .context .annotation .Configuration ;
2023import org .springframework .web .cors .CorsConfiguration ;
2124import org .springframework .web .cors .UrlBasedCorsConfigurationSource ;
2225import org .springframework .web .filter .CorsFilter ;
2528/**application
2629 * @author Lemon
2730 */
31+ @ Configuration
2832@ SpringBootApplication
2933public class APIJSONApplication {
3034
@@ -40,7 +44,7 @@ public static void main(String[] args) throws Exception {
4044 }
4145 System .out .println ("\n 完成测试:远程函数 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" );
4246
43-
47+
4448 System .out .println ("\n \n \n 开始测试:请求校验 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n " );
4549 try {
4650 StructureUtil .test ();
@@ -53,6 +57,16 @@ public static void main(String[] args) throws Exception {
5357 }
5458
5559
60+ @ Bean
61+ public EmbeddedServletContainerCustomizer containerCustomizer () {
62+ return new EmbeddedServletContainerCustomizer () {
63+
64+ @ Override
65+ public void customize (ConfigurableEmbeddedServletContainer container ) {
66+ container .setPort (8080 ); //自定义端口号,如果和 TiDB 等其它程序端口有冲突,可改为 8081, 9090, 9091 等未被占用的端口
67+ }
68+ };
69+ }
5670
5771 //支持JavaScript跨域请求<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
5872 /**
Original file line number Diff line number Diff line change 2828
2929
3030/**SQL配置
31+ * TiDB 用法和 MySQL 一致
3132 * @author Lemon
3233 */
3334public class DemoSQLConfig extends AbstractSQLConfig {
@@ -41,7 +42,7 @@ public class DemoSQLConfig extends AbstractSQLConfig {
4142
4243 @ Override
4344 public String getDBUri () {
44- //TODO 改成你自己的
45+ //TODO 改成你自己的,TiDB 默认端口为 4000
4546 return DATABASE_POSTGRESQL .equalsIgnoreCase (getDatabase ()) ? "jdbc:postgresql://localhost:5432/postgres" : "jdbc:mysql://localhost:3306" ;
4647 }
4748 @ Override
@@ -50,7 +51,7 @@ public String getDBAccount() {
5051 }
5152 @ Override
5253 public String getDBPassword () {
53- return DATABASE_POSTGRESQL .equalsIgnoreCase (getDatabase ()) ? null : "apijson" ; //TODO 改成你自己的
54+ return DATABASE_POSTGRESQL .equalsIgnoreCase (getDatabase ()) ? null : "apijson" ; //TODO 改成你自己的,TiDB 默认密码为空字符串 ""
5455 }
5556 @ Override
5657 public String getSchema () {
You can’t perform that action at this time.
0 commit comments