This is an automated email from the ASF dual-hosted git repository. liujun pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/dubbo-initializer.git
commit 1397b48742d6bbd2c51c3c84f22f4dd3ec69a207 Author: ICD <15835991...@163.com> AuthorDate: Sun Mar 26 20:35:10 2023 +0800 dubbo register code --- .../extension/SampleCodeContributor.java | 7 +- .../build/maven/ApiMavenPluginCustomizer.java | 7 +- ...ava => DefaultMavenDependenciesCustomizer.java} | 23 +- ... DubboMavenProjectGenerationConfiguration.java} | 13 +- .../codes/DubboSampleCodeContributor.java} | 42 ++-- ...boSourceCodeProjectGenerationConfiguration.java | 32 +++ .../DubboJavaProjectGenerationConfiguration.java | 17 ++ .../src/main/resources/META-INF/spring.factories | 4 +- .../src/main/resources/metadata.yaml | 29 ++- .../java/ConsumerApplication.java.mustache | 48 ---- .../resources/application.properties.mustache | 8 - .../consumer/resources/log4j.properties.mustache | 7 - .../pic/interface/java/DemoService.java.mustache | 29 --- .../provider/java/DemoServiceImpl.java.mustache | 34 --- .../provider/java/EmbeddedZooKeeper.java.mustache | 250 --------------------- .../java/ProviderApplication.java.mustache | 36 --- .../provider/java/TestSocketUtils.java.mustache | 109 --------- .../resources/application.properties.mustache | 8 - .../provider/resources/log4j.properties.mustache | 7 - .../resources/application.properties.mustache | 3 + .../codes/dubbo/api/java/DemoService.java.mustache | 7 + .../codes/dubbo/java/DemoServiceImpl.java.mustache | 12 + .../resources/application.properties.mustache | 1 + .../MybatisDemoConfig.java.mustache | 2 +- .../entity => java}/MybatisDemoUser.java.mustache | 2 +- .../MybatisDemoUserMapper.java.mustache | 2 +- .../resources/application.properties.mustache | 2 +- .../mappers/MybatisDemoUserMapper.xml.mustache | 4 +- 28 files changed, 139 insertions(+), 606 deletions(-) diff --git a/initializer-generator/src/main/java/com/alibaba/initializer/generation/extension/SampleCodeContributor.java b/initializer-generator/src/main/java/com/alibaba/initializer/generation/extension/SampleCodeContributor.java index 8b3d45b..b1ede7b 100644 --- a/initializer-generator/src/main/java/com/alibaba/initializer/generation/extension/SampleCodeContributor.java +++ b/initializer-generator/src/main/java/com/alibaba/initializer/generation/extension/SampleCodeContributor.java @@ -99,6 +99,7 @@ public class SampleCodeContributor implements ProjectContributor { params.put(BootstrapTemplateRenderConstants.KEY_SPRINGBOOT_VERSION, description.getPlatformVersion().toString()); params.put(BootstrapTemplateRenderConstants.KEY_JAVA_VERSION, description.getLanguage().jvmVersion()); params.put(KEY_ARTIFACT_ID, description.getArtifactId()); + params.put(BootstrapTemplateRenderConstants.KEY_MODULE, module.getName()); params.put(BootstrapTemplateRenderConstants.KEY_BASE_VERSION, description.getVersion()); SourceStructure structure = description.getBuildSystem().getMainSource(projectRoot, language); @@ -107,8 +108,10 @@ public class SampleCodeContributor implements ProjectContributor { Map<Dependency, String> dependencyRepoUris = getRepos(description); List<String> uris = new ArrayList<>(); dependencyRepoUris.values().forEach(uri -> { - uris.add(uri); - uris.add(uri + "/" + architecture.getId() + "/" + module.getName()); + if (module.isMain()) + uris.add(uri); + else + uris.add(uri + "/" + module.getName()); }); uris.forEach(uri -> { CodeTemplateRepo repo = loader.load(uri); diff --git a/initializer-generator/src/main/java/org/apache/dubbo/initializer/generation/extension/build/maven/ApiMavenPluginCustomizer.java b/initializer-generator/src/main/java/org/apache/dubbo/initializer/generation/extension/build/maven/ApiMavenPluginCustomizer.java index 96fcad9..8084e78 100644 --- a/initializer-generator/src/main/java/org/apache/dubbo/initializer/generation/extension/build/maven/ApiMavenPluginCustomizer.java +++ b/initializer-generator/src/main/java/org/apache/dubbo/initializer/generation/extension/build/maven/ApiMavenPluginCustomizer.java @@ -20,16 +20,13 @@ import io.spring.initializr.generator.buildsystem.maven.MavenBuild; import io.spring.initializr.generator.spring.build.BuildCustomizer; /** - * after DefaultStarterBuildCustomizer,SpringBootBomMavenCustomizer,MavenComplierPluginCustomizer + * after MavenComplierPluginCustomizer,SpringBootBomMavenCustomizer * <pre> * 1.Remove other all plugins from api module pom.xml - * 2.Remove starter dependencies from interface module pom.xml * </pre> * * @author Weix Sun - * @see io.spring.initializr.generator.spring.build.DefaultStarterBuildCustomizer - * com.alibaba.initializer.generation.extension.build.maven.MavenComplierPluginCustomizer - * com.alibaba.initializer.generation.extension.build.maven.SpringBootBomMavenCustomizer + * @see com.alibaba.initializer.generation.extension.build.maven.MavenComplierPluginCustomizer,com.alibaba.initializer.generation.extension.build.maven.SpringBootBomMavenCustomizer */ public class ApiMavenPluginCustomizer implements BuildCustomizer<MavenBuild> { diff --git a/initializer-generator/src/main/java/org/apache/dubbo/initializer/generation/extension/build/maven/DefaultMavenBomCustomizer.java b/initializer-generator/src/main/java/org/apache/dubbo/initializer/generation/extension/build/maven/DefaultMavenDependenciesCustomizer.java similarity index 60% rename from initializer-generator/src/main/java/org/apache/dubbo/initializer/generation/extension/build/maven/DefaultMavenBomCustomizer.java rename to initializer-generator/src/main/java/org/apache/dubbo/initializer/generation/extension/build/maven/DefaultMavenDependenciesCustomizer.java index cc9269a..d2ff94a 100644 --- a/initializer-generator/src/main/java/org/apache/dubbo/initializer/generation/extension/build/maven/DefaultMavenBomCustomizer.java +++ b/initializer-generator/src/main/java/org/apache/dubbo/initializer/generation/extension/build/maven/DefaultMavenDependenciesCustomizer.java @@ -20,27 +20,30 @@ import io.spring.initializr.generator.buildsystem.maven.MavenBuild; import io.spring.initializr.generator.spring.build.BuildCustomizer; /** - * after DefaultStarterBuildCustomizer, + * after DefaultStarterBuildCustomizer,DependencyManagementBuildCustomizer * <pre> - * 2.Remove starter dependencies from pom.xml + * 1.Remove starter dependencies from pom.xml + * 2.Remove other dependencies from pom.xml * </pre> * * @author Weix Sun - * @see io.spring.initializr.generator.spring.build.DefaultStarterBuildCustomizer + * @see io.spring.initializr.generator.spring.build.DefaultStarterBuildCustomizer,io.spring.initializr.generator.spring.build.DependencyManagementBuildCustomizer */ -public class DefaultMavenBomCustomizer implements BuildCustomizer<MavenBuild> { +public class DefaultMavenDependenciesCustomizer implements BuildCustomizer<MavenBuild> { static final String DEFAULT_STARTER = "root_starter"; static final String TEST_STARTER = "test"; @Override public void customize(MavenBuild build) { - if (build.dependencies().has(DEFAULT_STARTER)) { - build.dependencies().remove(DEFAULT_STARTER); - } - if (build.dependencies().has(TEST_STARTER)) { - build.dependencies().remove(TEST_STARTER); - } +// if (build.dependencies().has(DEFAULT_STARTER)) { +// build.dependencies().remove(DEFAULT_STARTER); +// } +// if (build.dependencies().has(TEST_STARTER)) { +// build.dependencies().remove(TEST_STARTER); +// } + // Remove all dependencies, after the 'dependencies.bom' analysis is completed + build.dependencies().ids().toList().forEach(id -> build.dependencies().remove(id)); } @Override diff --git a/initializer-generator/src/main/java/org/apache/dubbo/initializer/generation/extension/build/maven/DefaultMavenProjectGenerationConfiguration.java b/initializer-generator/src/main/java/org/apache/dubbo/initializer/generation/extension/build/maven/DubboMavenProjectGenerationConfiguration.java similarity index 78% rename from initializer-generator/src/main/java/org/apache/dubbo/initializer/generation/extension/build/maven/DefaultMavenProjectGenerationConfiguration.java rename to initializer-generator/src/main/java/org/apache/dubbo/initializer/generation/extension/build/maven/DubboMavenProjectGenerationConfiguration.java index 3db58fd..34b6b92 100644 --- a/initializer-generator/src/main/java/org/apache/dubbo/initializer/generation/extension/build/maven/DefaultMavenProjectGenerationConfiguration.java +++ b/initializer-generator/src/main/java/org/apache/dubbo/initializer/generation/extension/build/maven/DubboMavenProjectGenerationConfiguration.java @@ -16,7 +16,7 @@ package org.apache.dubbo.initializer.generation.extension.build.maven; -import com.alibaba.initializer.generation.condition.ConditionalOnModule; +import com.alibaba.initializer.generation.InitializerProjectGenerationConfiguration; import com.alibaba.initializer.generation.condition.ConditionalOnRequestedArchitecture; import io.spring.initializr.generator.buildsystem.maven.MavenBuildSystem; import io.spring.initializr.generator.condition.ConditionalOnBuildSystem; @@ -25,12 +25,12 @@ import org.apache.dubbo.initializer.generation.condition.ConditionalOnRequestedM import org.springframework.context.annotation.Bean; /** - * @author Weix Sun + * @author <a href="mailto:15835991...@163.com">ErDan Wang</a> */ -@ProjectGenerationConfiguration +@InitializerProjectGenerationConfiguration @ConditionalOnRequestedArchitecture("dubbo") @ConditionalOnBuildSystem(MavenBuildSystem.ID) -public class DefaultMavenProjectGenerationConfiguration { +public class DubboMavenProjectGenerationConfiguration { @Bean @ConditionalOnRequestedModule(value = "api") @@ -38,6 +38,7 @@ public class DefaultMavenProjectGenerationConfiguration { return new ApiMavenPluginCustomizer(); } + // Root Maven Bom remove in MulitModuleMavenBuildProjectContributor @Bean @ConditionalOnRequestedModule(value = "root") public RootMavenPluginCustomizer rootMavenPluginCustomizer() { @@ -46,8 +47,8 @@ public class DefaultMavenProjectGenerationConfiguration { @Bean @ConditionalOnRequestedModule({"root", "api"}) - public DefaultMavenBomCustomizer defaultMavenBomCustomizer() { - return new DefaultMavenBomCustomizer(); + public DefaultMavenDependenciesCustomizer defaultMavenDependenciesCustomizer() { + return new DefaultMavenDependenciesCustomizer(); } } diff --git a/initializer-generator/src/main/java/com/alibaba/initializer/generation/extension/SampleCodeContributor.java b/initializer-generator/src/main/java/org/apache/dubbo/initializer/generation/extension/codes/DubboSampleCodeContributor.java similarity index 94% copy from initializer-generator/src/main/java/com/alibaba/initializer/generation/extension/SampleCodeContributor.java copy to initializer-generator/src/main/java/org/apache/dubbo/initializer/generation/extension/codes/DubboSampleCodeContributor.java index 8b3d45b..890e4dc 100644 --- a/initializer-generator/src/main/java/com/alibaba/initializer/generation/extension/SampleCodeContributor.java +++ b/initializer-generator/src/main/java/org/apache/dubbo/initializer/generation/extension/codes/DubboSampleCodeContributor.java @@ -14,23 +14,7 @@ * limitations under the License. */ -package com.alibaba.initializer.generation.extension; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.StandardOpenOption; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Collectors; +package org.apache.dubbo.initializer.generation.extension.codes; import com.alibaba.initializer.core.constants.ErrorCodeEnum; import com.alibaba.initializer.core.exception.BizRuntimeException; @@ -39,12 +23,8 @@ import com.alibaba.initializer.core.template.CodeTemplateRepoRenderer; import com.alibaba.initializer.core.template.RepoRenderResult; import com.alibaba.initializer.core.template.loader.RootRepoTemplateLoader; import com.alibaba.initializer.generation.constants.BootstrapTemplateRenderConstants; -import com.alibaba.initializer.metadata.Architecture; -import com.alibaba.initializer.metadata.DependencyArchConfig; -import com.alibaba.initializer.metadata.EnhancedDependency; -import com.alibaba.initializer.metadata.InitializerMetadata; import com.alibaba.initializer.metadata.Module; -import com.alibaba.initializer.metadata.ModuleConfig; +import com.alibaba.initializer.metadata.*; import com.alibaba.initializer.project.InitializerProjectDescription; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; @@ -54,18 +34,29 @@ import io.spring.initializr.generator.language.SourceStructure; import io.spring.initializr.generator.project.contributor.ProjectContributor; import io.spring.initializr.metadata.DependencyGroup; import org.apache.commons.lang3.StringUtils; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.util.CollectionUtils; import org.springframework.util.FileCopyUtils; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardOpenOption; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + import static com.alibaba.initializer.generation.constants.BootstrapTemplateRenderConstants.KEY_ARTIFACT_ID; /** - * @author <a href="mailto:chenxil...@gmail.com">theonefx</a> + * @author @author <a href="mailto:15835991...@163.com">ErDan Wang</a> */ -public class SampleCodeContributor implements ProjectContributor { +public class DubboSampleCodeContributor implements ProjectContributor { @Value("${application.democode-path}") private String templates; @@ -99,6 +90,7 @@ public class SampleCodeContributor implements ProjectContributor { params.put(BootstrapTemplateRenderConstants.KEY_SPRINGBOOT_VERSION, description.getPlatformVersion().toString()); params.put(BootstrapTemplateRenderConstants.KEY_JAVA_VERSION, description.getLanguage().jvmVersion()); params.put(KEY_ARTIFACT_ID, description.getArtifactId()); + params.put(BootstrapTemplateRenderConstants.KEY_MODULE, module.getName()); params.put(BootstrapTemplateRenderConstants.KEY_BASE_VERSION, description.getVersion()); SourceStructure structure = description.getBuildSystem().getMainSource(projectRoot, language); diff --git a/initializer-generator/src/main/java/org/apache/dubbo/initializer/generation/extension/codes/DubboSourceCodeProjectGenerationConfiguration.java b/initializer-generator/src/main/java/org/apache/dubbo/initializer/generation/extension/codes/DubboSourceCodeProjectGenerationConfiguration.java new file mode 100644 index 0000000..96f11a0 --- /dev/null +++ b/initializer-generator/src/main/java/org/apache/dubbo/initializer/generation/extension/codes/DubboSourceCodeProjectGenerationConfiguration.java @@ -0,0 +1,32 @@ +package org.apache.dubbo.initializer.generation.extension.codes; + +import com.alibaba.initializer.generation.InitializerProjectGenerationConfiguration; +import com.alibaba.initializer.generation.condition.ConditionalOnModule; +import com.alibaba.initializer.generation.condition.ConditionalOnRequestedArchitecture; +import com.alibaba.initializer.generation.extension.SampleCodeContributor; +import io.spring.initializr.generator.condition.ConditionalOnLanguage; +import io.spring.initializr.generator.condition.ConditionalOnRequestedDependency; +import io.spring.initializr.generator.language.Annotation; +import io.spring.initializr.generator.language.TypeDeclaration; +import io.spring.initializr.generator.language.java.JavaLanguage; +import io.spring.initializr.generator.spring.code.MainApplicationTypeCustomizer; +import org.springframework.context.annotation.Bean; + +@InitializerProjectGenerationConfiguration +@ConditionalOnRequestedArchitecture("dubbo") +@ConditionalOnModule(main = true) +@ConditionalOnLanguage(JavaLanguage.ID) +public class DubboSourceCodeProjectGenerationConfiguration { + @Bean + @ConditionalOnRequestedDependency("dubbo") + public MainApplicationTypeCustomizer<TypeDeclaration> enableDubboAnnotator() { + return (typeDeclaration) -> { + typeDeclaration.annotate(Annotation.name("org.apache.dubbo.config.spring.context.annotation.EnableDubbo")); + }; + } + +// @Bean +// public DubboSampleCodeContributor dubboSampleCodeContributor() { +// return new DubboSampleCodeContributor(); +// } +} diff --git a/initializer-generator/src/main/java/org/apache/dubbo/initializer/generation/extension/codes/language/DubboJavaProjectGenerationConfiguration.java b/initializer-generator/src/main/java/org/apache/dubbo/initializer/generation/extension/codes/language/DubboJavaProjectGenerationConfiguration.java new file mode 100644 index 0000000..acba1a9 --- /dev/null +++ b/initializer-generator/src/main/java/org/apache/dubbo/initializer/generation/extension/codes/language/DubboJavaProjectGenerationConfiguration.java @@ -0,0 +1,17 @@ +package org.apache.dubbo.initializer.generation.extension.codes.language; + +import com.alibaba.initializer.generation.InitializerProjectGenerationConfiguration; +import com.alibaba.initializer.generation.condition.ConditionalOnModule; +import com.alibaba.initializer.generation.condition.ConditionalOnRequestedArchitecture; +import io.spring.initializr.generator.condition.ConditionalOnLanguage; +import io.spring.initializr.generator.language.java.JavaLanguage; + +/** + * @author <a href="mailto:15835991...@163.com">ErDan Wang</a> + */ +@InitializerProjectGenerationConfiguration +@ConditionalOnRequestedArchitecture("dubbo") +@ConditionalOnModule(main = true) +@ConditionalOnLanguage(JavaLanguage.ID) +public class DubboJavaProjectGenerationConfiguration { +} diff --git a/initializer-generator/src/main/resources/META-INF/spring.factories b/initializer-generator/src/main/resources/META-INF/spring.factories index ded08e0..3780841 100644 --- a/initializer-generator/src/main/resources/META-INF/spring.factories +++ b/initializer-generator/src/main/resources/META-INF/spring.factories @@ -5,7 +5,9 @@ com.alibaba.initializer.generation.extension.codes.language.ArchedGroovyProjectG com.alibaba.initializer.generation.extension.codes.language.ArchedKotlinProjectGenerationConfiguration,\ com.alibaba.initializer.generation.extension.build.gradle.ArchedGradleProjectGenerationConfiguration,\ io.spring.start.site.extension.build.gradle.GradleProjectGenerationConfiguration,\ -org.apache.dubbo.initializer.generation.extension.build.maven.DefaultMavenProjectGenerationConfiguration,\ +org.apache.dubbo.initializer.generation.extension.build.maven.DubboMavenProjectGenerationConfiguration,\ +org.apache.dubbo.initializer.generation.extension.codes.DubboSourceCodeProjectGenerationConfiguration,\ +org.apache.dubbo.initializer.generation.extension.codes.language.DubboJavaProjectGenerationConfiguration,\ org.apache.dubbo.initializer.generation.extension.dependency.dubbregisterzookeeper.DubboRegisterZookeeperProjectGenerationConfiguration,\ com.alibaba.initializer.generation.extension.build.maven.ArchedMavenProjectGenerationConfiguration,\ io.spring.start.site.extension.build.maven.MavenProjectGenerationConfiguration,\ diff --git a/initializer-generator/src/main/resources/metadata.yaml b/initializer-generator/src/main/resources/metadata.yaml index 278ea73..34a3b06 100644 --- a/initializer-generator/src/main/resources/metadata.yaml +++ b/initializer-generator/src/main/resources/metadata.yaml @@ -8,7 +8,7 @@ initializr: mappings: - compatibilityRange: "2.3.0.M1" version: 3.0.7 - apache-dubbo-dependencies-zookeeper: + apache-dubbo-zookeeper: groupId: org.apache.dubbo artifactId: dubbo-dependencies-zookeeper versionProperty: dubbo.version @@ -221,35 +221,34 @@ initializr: snapshotsEnabled: true dependencies: - name: Dubbo Core + bom: apache-dubbo content: - name: Dubbo Spring Boot - id: dubbo-spring-boot-starter + id: dubbo groupId: org.apache.dubbo artifactId: dubbo-spring-boot-starter - description: dubbo-spring-boot-starter + description: Dubbo Spring Boot starter: false + archCfg: + dubbo: + modules: + api: + code: true + service: + code: true - name: Dubbo Registry content: - name: Zookeeper 注册中心 - id: dubbo-register-zookeeper + id: dubbo-zookeeper groupId: org.apache.dubbo artifactId: dubbo-dependencies-zookeeper type: pom description: 使用Zookeeper作为Dubbo注册中心 starter: false compatibilityRange: "[2.0.0.RELEASE,3.1.0-M1)" - bom: apache-dubbo-dependencies-zookeeper + bom: apache-dubbo-zookeeper codeOnly: false - dependencies: [ "metrics-core" ] - archCfg: - pic: - modules: - provider: - code: true - interface: - code: true - consumer: - code: true + #dependencies: [ "metrics-core" ] - name: metrics-core id: metrics-core groupId: io.dropwizard.metrics diff --git a/initializer-generator/src/main/resources/templates/codes/dubbo-register-zookeeper/pic/consumer/java/ConsumerApplication.java.mustache b/initializer-generator/src/main/resources/templates/codes/dubbo-register-zookeeper/pic/consumer/java/ConsumerApplication.java.mustache deleted file mode 100644 index 04492ab..0000000 --- a/initializer-generator/src/main/resources/templates/codes/dubbo-register-zookeeper/pic/consumer/java/ConsumerApplication.java.mustache +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package {{basePackage}}.consumer; - -import org.apache.dubbo.config.annotation.DubboReference; -import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; -import {{basePackage}}.DemoService; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.stereotype.Service; - -@SpringBootApplication -@Service -@EnableDubbo -public class ConsumerApplication { - - @DubboReference - private DemoService demoService; - - public static void main(String[] args) { - - ConfigurableApplicationContext context = SpringApplication.run(ConsumerApplication.class, args); - ConsumerApplication application = context.getBean(ConsumerApplication.class); - String result = application.doSayHello("world"); - System.out.println("result: " + result); - } - - public String doSayHello(String name) { - return demoService.sayHello(name); - } -} diff --git a/initializer-generator/src/main/resources/templates/codes/dubbo-register-zookeeper/pic/consumer/resources/application.properties.mustache b/initializer-generator/src/main/resources/templates/codes/dubbo-register-zookeeper/pic/consumer/resources/application.properties.mustache deleted file mode 100644 index 639adae..0000000 --- a/initializer-generator/src/main/resources/templates/codes/dubbo-register-zookeeper/pic/consumer/resources/application.properties.mustache +++ /dev/null @@ -1,8 +0,0 @@ -dubbo.application.name=consumer -dubbo.protocol.name=dubbo -dubbo.protocol.port=-1 -dubbo.registry.id=zk-registry -dubbo.registry.address=zookeeper://127.0.0.1:2181 -dubbo.config-center.address=zookeeper://127.0.0.1:2181 -dubbo.metadata-report.address=zookeeper://127.0.0.1:2181 -dubbo.service.{{basePackage}}.serialization=fastjson2 \ No newline at end of file diff --git a/initializer-generator/src/main/resources/templates/codes/dubbo-register-zookeeper/pic/consumer/resources/log4j.properties.mustache b/initializer-generator/src/main/resources/templates/codes/dubbo-register-zookeeper/pic/consumer/resources/log4j.properties.mustache deleted file mode 100644 index 8de4c4f..0000000 --- a/initializer-generator/src/main/resources/templates/codes/dubbo-register-zookeeper/pic/consumer/resources/log4j.properties.mustache +++ /dev/null @@ -1,7 +0,0 @@ -###set log levels### -log4j.rootLogger=info, stdout -###output to the console### -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.Target=System.out -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=[%d{dd/MM/yy HH:mm:ss:SSS z}] %t %5p %c{2}: %m%n diff --git a/initializer-generator/src/main/resources/templates/codes/dubbo-register-zookeeper/pic/interface/java/DemoService.java.mustache b/initializer-generator/src/main/resources/templates/codes/dubbo-register-zookeeper/pic/interface/java/DemoService.java.mustache deleted file mode 100644 index 5e5e489..0000000 --- a/initializer-generator/src/main/resources/templates/codes/dubbo-register-zookeeper/pic/interface/java/DemoService.java.mustache +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package {{basePackage}}; - -import java.util.concurrent.CompletableFuture; - -public interface DemoService { - - String sayHello(String name); - - default CompletableFuture<String> sayHelloAsync(String name) { - return CompletableFuture.completedFuture(sayHello(name)); - } - -} diff --git a/initializer-generator/src/main/resources/templates/codes/dubbo-register-zookeeper/pic/provider/java/DemoServiceImpl.java.mustache b/initializer-generator/src/main/resources/templates/codes/dubbo-register-zookeeper/pic/provider/java/DemoServiceImpl.java.mustache deleted file mode 100644 index 4bbda39..0000000 --- a/initializer-generator/src/main/resources/templates/codes/dubbo-register-zookeeper/pic/provider/java/DemoServiceImpl.java.mustache +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package {{basePackage}}.provider; - - -import org.apache.dubbo.config.annotation.DubboService; -import org.apache.dubbo.rpc.RpcContext; -import {{basePackage}}.DemoService; - -@DubboService -public class DemoServiceImpl implements DemoService { - - @Override - public String sayHello(String name) { - System.out.println("Hello " + name + ", request from consumer: " + RpcContext.getContext().getRemoteAddress()); - return "Hello " + name; - } - - -} diff --git a/initializer-generator/src/main/resources/templates/codes/dubbo-register-zookeeper/pic/provider/java/EmbeddedZooKeeper.java.mustache b/initializer-generator/src/main/resources/templates/codes/dubbo-register-zookeeper/pic/provider/java/EmbeddedZooKeeper.java.mustache deleted file mode 100644 index 2e4601d..0000000 --- a/initializer-generator/src/main/resources/templates/codes/dubbo-register-zookeeper/pic/provider/java/EmbeddedZooKeeper.java.mustache +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package {{basePackage}}.provider; - -import org.apache.zookeeper.server.ServerConfig; -import org.apache.zookeeper.server.ZooKeeperServerMain; -import org.apache.zookeeper.server.quorum.QuorumPeerConfig; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.context.SmartLifecycle; -import org.springframework.util.ErrorHandler; - -import java.io.File; -import java.lang.reflect.Method; -import java.util.Properties; -import java.util.UUID; - -/** - * from: https://github.com/spring-projects/spring-xd/blob/v1.3.1.RELEASE/spring-xd-dirt/src/main/java/org/springframework/xd/dirt/zookeeper/ZooKeeperUtils.java - * <p> - * Helper class to start an embedded instance of standalone (non clustered) ZooKeeper. - * <p> - * NOTE: at least an external standalone server (if not an ensemble) are recommended, even for - * {@link org.springframework.xd.dirt.server.singlenode.SingleNodeApplication} - * - * @author Patrick Peralta - * @author Mark Fisher - * @author David Turanski - */ -public class EmbeddedZooKeeper implements SmartLifecycle { - - /** - * Logger. - */ - private static final Logger logger = LoggerFactory.getLogger(EmbeddedZooKeeper.class); - - /** - * ZooKeeper client port. This will be determined dynamically upon startup. - */ - private final int clientPort; - - /** - * Whether to auto-start. Default is true. - */ - private boolean autoStartup = true; - - /** - * Lifecycle phase. Default is 0. - */ - private int phase = 0; - - /** - * Thread for running the ZooKeeper server. - */ - private volatile Thread zkServerThread; - - /** - * ZooKeeper server. - */ - private volatile ZooKeeperServerMain zkServer; - - /** - * {@link ErrorHandler} to be invoked if an Exception is thrown from the ZooKeeper server thread. - */ - private ErrorHandler errorHandler; - - private boolean daemon = true; - - /** - * Construct an EmbeddedZooKeeper with a random port. - */ - public EmbeddedZooKeeper() { - clientPort = TestSocketUtils.findAvailableTcpPort(); - } - - /** - * Construct an EmbeddedZooKeeper with the provided port. - * - * @param clientPort port for ZooKeeper server to bind to - */ - public EmbeddedZooKeeper(int clientPort, boolean daemon) { - this.clientPort = clientPort; - this.daemon = daemon; - } - - /** - * Returns the port that clients should use to connect to this embedded server. - * - * @return dynamically determined client port - */ - public int getClientPort() { - return this.clientPort; - } - - /** - * Specify whether to start automatically. Default is true. - * - * @param autoStartup whether to start automatically - */ - public void setAutoStartup(boolean autoStartup) { - this.autoStartup = autoStartup; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isAutoStartup() { - return this.autoStartup; - } - - /** - * Specify the lifecycle phase for the embedded server. - * - * @param phase the lifecycle phase - */ - public void setPhase(int phase) { - this.phase = phase; - } - - /** - * {@inheritDoc} - */ - @Override - public int getPhase() { - return this.phase; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isRunning() { - return (zkServerThread != null); - } - - /** - * Start the ZooKeeper server in a background thread. - * <p> - * Register an error handler via {@link #setErrorHandler} in order to handle - * any exceptions thrown during startup or execution. - */ - @Override - public synchronized void start() { - if (zkServerThread == null) { - zkServerThread = new Thread(new ServerRunnable(), "ZooKeeper Server Starter"); - zkServerThread.setDaemon(daemon); - zkServerThread.start(); - } - } - - /** - * Shutdown the ZooKeeper server. - */ - @Override - public synchronized void stop() { - if (zkServerThread != null) { - // The shutdown method is protected...thus this hack to invoke it. - // This will log an exception on shutdown; see - // https://issues.apache.org/jira/browse/ZOOKEEPER-1873 for details. - try { - Method shutdown = ZooKeeperServerMain.class.getDeclaredMethod("shutdown"); - shutdown.setAccessible(true); - shutdown.invoke(zkServer); - } catch (Exception e) { - throw new RuntimeException(e); - } - - // It is expected that the thread will exit after - // the server is shutdown; this will block until - // the shutdown is complete. - try { - zkServerThread.join(5000); - zkServerThread = null; - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - logger.warn("Interrupted while waiting for embedded ZooKeeper to exit"); - // abandoning zk thread - zkServerThread = null; - } - } - } - - /** - * Stop the server if running and invoke the callback when complete. - */ - @Override - public void stop(Runnable callback) { - stop(); - callback.run(); - } - - /** - * Provide an {@link ErrorHandler} to be invoked if an Exception is thrown from the ZooKeeper server thread. If none - * is provided, only error-level logging will occur. - * - * @param errorHandler the {@link ErrorHandler} to be invoked - */ - public void setErrorHandler(ErrorHandler errorHandler) { - this.errorHandler = errorHandler; - } - - /** - * Runnable implementation that starts the ZooKeeper server. - */ - private class ServerRunnable implements Runnable { - - @Override - public void run() { - try { - Properties properties = new Properties(); - File file = new File(System.getProperty("java.io.tmpdir") - + File.separator + UUID.randomUUID()); - file.deleteOnExit(); - properties.setProperty("dataDir", file.getAbsolutePath()); - properties.setProperty("clientPort", String.valueOf(clientPort)); - - QuorumPeerConfig quorumPeerConfig = new QuorumPeerConfig(); - quorumPeerConfig.parseProperties(properties); - - zkServer = new ZooKeeperServerMain(); - ServerConfig configuration = new ServerConfig(); - configuration.readFrom(quorumPeerConfig); - - zkServer.runFromConfig(configuration); - } catch (Exception e) { - if (errorHandler != null) { - errorHandler.handleError(e); - } else { - logger.error("Exception running embedded ZooKeeper", e); - } - } - } - } - -} diff --git a/initializer-generator/src/main/resources/templates/codes/dubbo-register-zookeeper/pic/provider/java/ProviderApplication.java.mustache b/initializer-generator/src/main/resources/templates/codes/dubbo-register-zookeeper/pic/provider/java/ProviderApplication.java.mustache deleted file mode 100644 index d0bdc60..0000000 --- a/initializer-generator/src/main/resources/templates/codes/dubbo-register-zookeeper/pic/provider/java/ProviderApplication.java.mustache +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package {{basePackage}}.provider; - - -import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -@EnableDubbo -public class ProviderApplication { - public static void main(String[] args) throws Exception { - new EmbeddedZooKeeper(2181, false).start(); - - SpringApplication.run(ProviderApplication.class, args); - System.out.println("dubbo service started"); -// new CountDownLatch(1).await(); - } -} diff --git a/initializer-generator/src/main/resources/templates/codes/dubbo-register-zookeeper/pic/provider/java/TestSocketUtils.java.mustache b/initializer-generator/src/main/resources/templates/codes/dubbo-register-zookeeper/pic/provider/java/TestSocketUtils.java.mustache deleted file mode 100644 index d2f3062..0000000 --- a/initializer-generator/src/main/resources/templates/codes/dubbo-register-zookeeper/pic/provider/java/TestSocketUtils.java.mustache +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package {{basePackage}}.provider; - -import java.net.InetAddress; -import java.net.ServerSocket; -import java.util.Random; - -import javax.net.ServerSocketFactory; - -import org.apache.dubbo.common.utils.Assert; - -/** - * Simple utility for finding available TCP ports on {@code localhost} for use in - * integration testing scenarios. - * - * <p>{@code TestSocketUtils} can be used in integration tests which start an - * external server on an available random port. However, these utilities make no - * guarantee about the subsequent availability of a given port and are therefore - * unreliable. Instead of using {@code TestSocketUtils} to find an available local - * port for a server, it is recommended that you rely on a server's ability to - * start on a random <em>ephemeral</em> port that it selects or is assigned by the - * operating system. To interact with that server, you should query the server - * for the port it is currently using. - * - * @since 3.2 - */ -public class TestSocketUtils { - - /** - * The minimum value for port ranges used when finding an available TCP port. - */ - static final int PORT_RANGE_MIN = 1024; - - /** - * The maximum value for port ranges used when finding an available TCP port. - */ - static final int PORT_RANGE_MAX = 65535; - - private static final int PORT_RANGE_PLUS_ONE = PORT_RANGE_MAX - PORT_RANGE_MIN + 1; - - private static final int MAX_ATTEMPTS = 1_000; - - private static final Random random = new Random(System.nanoTime()); - - private static final TestSocketUtils INSTANCE = new TestSocketUtils(); - - private TestSocketUtils() { - } - - /** - * Find an available TCP port randomly selected from the range [1024, 65535]. - * @return an available TCP port number - * @throws IllegalStateException if no available port could be found - */ - public static int findAvailableTcpPort() { - return INSTANCE.findAvailableTcpPortInternal(); - } - - - /** - * Internal implementation of {@link #findAvailableTcpPort()}. - * <p>Package-private solely for testing purposes. - */ - int findAvailableTcpPortInternal() { - int candidatePort; - int searchCounter = 0; - do { - Assert.assertTrue(++searchCounter <= MAX_ATTEMPTS, String.format( - "Could not find an available TCP port in the range [%d, %d] after %d attempts", - PORT_RANGE_MIN, PORT_RANGE_MAX, MAX_ATTEMPTS)); - candidatePort = PORT_RANGE_MIN + random.nextInt(PORT_RANGE_PLUS_ONE); - } - while (!isPortAvailable(candidatePort)); - - return candidatePort; - } - - /** - * Determine if the specified TCP port is currently available on {@code localhost}. - * <p>Package-private solely for testing purposes. - */ - boolean isPortAvailable(int port) { - try { - ServerSocket serverSocket = ServerSocketFactory.getDefault() - .createServerSocket(port, 1, InetAddress.getByName("localhost")); - serverSocket.close(); - return true; - } - catch (Exception ex) { - return false; - } - } - -} diff --git a/initializer-generator/src/main/resources/templates/codes/dubbo-register-zookeeper/pic/provider/resources/application.properties.mustache b/initializer-generator/src/main/resources/templates/codes/dubbo-register-zookeeper/pic/provider/resources/application.properties.mustache deleted file mode 100644 index bb59e1f..0000000 --- a/initializer-generator/src/main/resources/templates/codes/dubbo-register-zookeeper/pic/provider/resources/application.properties.mustache +++ /dev/null @@ -1,8 +0,0 @@ -dubbo.application.name=provider -dubbo.protocol.name=dubbo -dubbo.protocol.port=-1 -dubbo.registry.id=zk-registry -dubbo.registry.address=zookeeper://127.0.0.1:2181 -dubbo.config-center.address=zookeeper://127.0.0.1:2181 -dubbo.metadata-report.address=zookeeper://127.0.0.1:2181 -dubbo.service.{{basePackage}}.serialization=fastjson2 \ No newline at end of file diff --git a/initializer-generator/src/main/resources/templates/codes/dubbo-register-zookeeper/pic/provider/resources/log4j.properties.mustache b/initializer-generator/src/main/resources/templates/codes/dubbo-register-zookeeper/pic/provider/resources/log4j.properties.mustache deleted file mode 100644 index 8de4c4f..0000000 --- a/initializer-generator/src/main/resources/templates/codes/dubbo-register-zookeeper/pic/provider/resources/log4j.properties.mustache +++ /dev/null @@ -1,7 +0,0 @@ -###set log levels### -log4j.rootLogger=info, stdout -###output to the console### -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.Target=System.out -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=[%d{dd/MM/yy HH:mm:ss:SSS z}] %t %5p %c{2}: %m%n diff --git a/initializer-generator/src/main/resources/templates/codes/dubbo-zookeeper/resources/application.properties.mustache b/initializer-generator/src/main/resources/templates/codes/dubbo-zookeeper/resources/application.properties.mustache new file mode 100644 index 0000000..6334cf1 --- /dev/null +++ b/initializer-generator/src/main/resources/templates/codes/dubbo-zookeeper/resources/application.properties.mustache @@ -0,0 +1,3 @@ +# dubbo zookeeper https://cn.dubbo.apache.org/zh-cn/overview/mannual/java-sdk/reference-manual/registry/zookeeper/ +# Registry 配置项手册 https://cn.dubbo.apache.org/zh-cn/overview/mannual/java-sdk/reference-manual/config/properties/#registry +dubbo.registry.address=zookeeper://${zookeeper.address:127.0.0.1}:2181 \ No newline at end of file diff --git a/initializer-generator/src/main/resources/templates/codes/dubbo/api/java/DemoService.java.mustache b/initializer-generator/src/main/resources/templates/codes/dubbo/api/java/DemoService.java.mustache new file mode 100644 index 0000000..4c44e3d --- /dev/null +++ b/initializer-generator/src/main/resources/templates/codes/dubbo/api/java/DemoService.java.mustache @@ -0,0 +1,7 @@ +package {{basePackage}}.service; + +public interface DemoService { + + String sayHello(String name); + +} diff --git a/initializer-generator/src/main/resources/templates/codes/dubbo/java/DemoServiceImpl.java.mustache b/initializer-generator/src/main/resources/templates/codes/dubbo/java/DemoServiceImpl.java.mustache new file mode 100644 index 0000000..b16417d --- /dev/null +++ b/initializer-generator/src/main/resources/templates/codes/dubbo/java/DemoServiceImpl.java.mustache @@ -0,0 +1,12 @@ +package {{basePackage}}.service; + +import org.apache.dubbo.config.annotation.DubboService; + +@DubboService +public class DemoServiceImpl implements DemoService { + + @Override + public String sayHello(String name) { + return "Hello " + name; + } +} \ No newline at end of file diff --git a/initializer-generator/src/main/resources/templates/codes/dubbo/resources/application.properties.mustache b/initializer-generator/src/main/resources/templates/codes/dubbo/resources/application.properties.mustache new file mode 100644 index 0000000..b76f186 --- /dev/null +++ b/initializer-generator/src/main/resources/templates/codes/dubbo/resources/application.properties.mustache @@ -0,0 +1 @@ +dubbo.application.name={{appShotName}}-{{module}} \ No newline at end of file diff --git a/initializer-generator/src/main/resources/templates/codes/mybatis/mybatis/java/config/MybatisDemoConfig.java.mustache b/initializer-generator/src/main/resources/templates/codes/mybatis/java/MybatisDemoConfig.java.mustache similarity index 96% rename from initializer-generator/src/main/resources/templates/codes/mybatis/mybatis/java/config/MybatisDemoConfig.java.mustache rename to initializer-generator/src/main/resources/templates/codes/mybatis/java/MybatisDemoConfig.java.mustache index d9f2319..1b6e81c 100644 --- a/initializer-generator/src/main/resources/templates/codes/mybatis/mybatis/java/config/MybatisDemoConfig.java.mustache +++ b/initializer-generator/src/main/resources/templates/codes/mybatis/java/MybatisDemoConfig.java.mustache @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package {{basePackage}}.mybatis.config; +package {{basePackage}}.config; import org.mybatis.spring.annotation.MapperScan; diff --git a/initializer-generator/src/main/resources/templates/codes/mybatis/mybatis/java/entity/MybatisDemoUser.java.mustache b/initializer-generator/src/main/resources/templates/codes/mybatis/java/MybatisDemoUser.java.mustache similarity index 97% rename from initializer-generator/src/main/resources/templates/codes/mybatis/mybatis/java/entity/MybatisDemoUser.java.mustache rename to initializer-generator/src/main/resources/templates/codes/mybatis/java/MybatisDemoUser.java.mustache index ecaed2a..91dc86f 100644 --- a/initializer-generator/src/main/resources/templates/codes/mybatis/mybatis/java/entity/MybatisDemoUser.java.mustache +++ b/initializer-generator/src/main/resources/templates/codes/mybatis/java/MybatisDemoUser.java.mustache @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package {{basePackage}}.mybatis.entity; +package {{basePackage}}.entity; import java.io.Serializable; diff --git a/initializer-generator/src/main/resources/templates/codes/mybatis/mybatis/java/mapper/MybatisDemoUserMapper.java.mustache b/initializer-generator/src/main/resources/templates/codes/mybatis/java/MybatisDemoUserMapper.java.mustache similarity index 96% rename from initializer-generator/src/main/resources/templates/codes/mybatis/mybatis/java/mapper/MybatisDemoUserMapper.java.mustache rename to initializer-generator/src/main/resources/templates/codes/mybatis/java/MybatisDemoUserMapper.java.mustache index 554e0b2..99d5f85 100644 --- a/initializer-generator/src/main/resources/templates/codes/mybatis/mybatis/java/mapper/MybatisDemoUserMapper.java.mustache +++ b/initializer-generator/src/main/resources/templates/codes/mybatis/java/MybatisDemoUserMapper.java.mustache @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package {{basePackage}}.mybatis.mapper; +package {{basePackage}}.mapper; import java.util.List; diff --git a/initializer-generator/src/main/resources/templates/codes/mybatis/resources/application.properties.mustache b/initializer-generator/src/main/resources/templates/codes/mybatis/resources/application.properties.mustache index 5463d86..09d4b99 100644 --- a/initializer-generator/src/main/resources/templates/codes/mybatis/resources/application.properties.mustache +++ b/initializer-generator/src/main/resources/templates/codes/mybatis/resources/application.properties.mustache @@ -3,5 +3,5 @@ #指定Mybatis的Mapper文件 mybatis.mapper-locations=classpath:mappers/*xml #指定Mybatis的实体目录 -mybatis.type-aliases-package={{basePackage}}.mybatis.entity +mybatis.type-aliases-package={{basePackage}}.entity diff --git a/initializer-generator/src/main/resources/templates/codes/mybatis/mybatis/resources/mappers/MybatisDemoUserMapper.xml.mustache b/initializer-generator/src/main/resources/templates/codes/mybatis/resources/mappers/MybatisDemoUserMapper.xml.mustache similarity index 53% rename from initializer-generator/src/main/resources/templates/codes/mybatis/mybatis/resources/mappers/MybatisDemoUserMapper.xml.mustache rename to initializer-generator/src/main/resources/templates/codes/mybatis/resources/mappers/MybatisDemoUserMapper.xml.mustache index afbf847..89a05ba 100644 --- a/initializer-generator/src/main/resources/templates/codes/mybatis/mybatis/resources/mappers/MybatisDemoUserMapper.xml.mustache +++ b/initializer-generator/src/main/resources/templates/codes/mybatis/resources/mappers/MybatisDemoUserMapper.xml.mustache @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > -<mapper namespace="{{basePackage}}.mybatis.mapper.MybatisDemoUserMapper"> - <select id="findAll" resultType="{{basePackage}}.mybatis.entity.MybatisDemoUser"> +<mapper namespace="{{basePackage}}.mapper.MybatisDemoUserMapper"> + <select id="findAll" resultType="{{basePackage}}.entity.MybatisDemoUser"> SELECT * FROM tb_user </select> </mapper> \ No newline at end of file