Skip to content

Commit

Permalink
fix: database not init
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhouYixun committed Mar 20, 2023
1 parent 6f79ee5 commit 466989a
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 7 deletions.
1 change: 0 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<current.version>SONIC_VERSION</current.version>
</properties>

Expand Down
4 changes: 3 additions & 1 deletion sonic-server-common/src/main/resources/application-jdbc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ spring:
username: ${MYSQL_USERNAME:root}
# mysql password
password: ${MYSQL_PASSWORD:Sonic!@#123}
initialization-mode: always
schema:
- classpath:data.sql
sql:
init:
mode: always

mybatis-plus:
mapper-locations: classpath*:com/gitee/sunchenbin/mybatis/actable/mapping/*/*.xml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@
*/
package org.cloud.sonic.controller;

import com.gitee.sunchenbin.mybatis.actable.manager.handler.StartUpHandler;
import org.cloud.sonic.controller.tools.SpringTool;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;

Expand All @@ -48,8 +46,6 @@
@Import(SpringTool.class)
public class ControllerApplication {
public static void main(String[] args) {
ConfigurableApplicationContext run = SpringApplication.run(ControllerApplication.class, args);
StartUpHandler createTable = run.getBean(StartUpHandler.class, args);
createTable.startHandler();
SpringApplication.run(ControllerApplication.class, args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* sonic-server Sonic Cloud Real Machine Platform.
* Copyright (C) 2022 SonicCloudOrg
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.cloud.sonic.controller.config.mybatis;

import com.gitee.sunchenbin.mybatis.actable.manager.handler.StartUpHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;

@Configuration
@Order(1)
public class ActableConfig {

@Autowired
private StartUpHandler startUpHandler;

@Bean
public void generate() {
startUpHandler.startHandler();
}
}

0 comments on commit 466989a

Please sign in to comment.