com.lq.cli.init.CreateApplicationXmlTask Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of springboot-dagger Show documentation
Show all versions of springboot-dagger Show documentation
Fast construction of springboot microservices
package com.lq.cli.init;
import com.lq.cli.comment.CreateTask;
import com.lq.cli.comment.FileUtil;
import com.lq.cli.comment.TaskArgs;
import java.io.File;
public class CreateApplicationXmlTask extends CreateTask {
public CreateApplicationXmlTask(TaskArgs taskArgs) {
super(taskArgs);
}
@Override
public Boolean call() throws Exception {
String path = taskArgs.projectPath + File.separator + "src" + File.separator + "main"
+ File.separator + "resources" + File.separator + "application.yml";
File file = new File(path);
if (!file.exists()) {
if (!file.createNewFile()) {
return false;
} else {
StringBuilder sb = new StringBuilder();
sb.append("spring: \n datasource: \n username: ")
.append(taskArgs.jdbcConfig.getUsername())
.append("\n password: ").append(taskArgs.jdbcConfig.getPassword())
.append("\n url: ").append(taskArgs.jdbcConfig.getUrl())
.append("\n driver-class-name: ").append(taskArgs.jdbcConfig.getDriverClassName());
if (taskArgs.cliConfig.isUseDruid()) {
sb.append("\n type: ").append("com.alibaba.druid.pool.DruidDataSource");
}
if (taskArgs.cliConfig.isUseRedis()) {
sb.append("\n redis: \n host: ").append("127.0.0.1")
.append("\n port: ").append("6379")
.append("\n database: ").append("0")
.append("\n timeout: ").append("3000")
.append("\n jedis: \n pool: ")
.append("\n max-idle: ").append("10")
.append("\n min-idle: ").append("5")
.append("\n max-active: ").append("30");
}
sb.append("\n\nmybatis:\n mapper-locations: classpath:mapper/*.xml\n configuration: \n log-impl: org.apache.ibatis.logging.stdout.StdOutImpl\n map-underscore-to-camel-case: true");
FileUtil.createWriteFile(file, sb.toString());
}
}
return true;
}
}