pom.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/org/yeshi/utils/generater/GeneraterManagerV2.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/org/yeshi/utils/generater/util/NameUtil.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/org/yeshi/utils/generater/vo/xmlconfig/XmlConfigParseUtil.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/resources/assembly.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
pom.xml
@@ -267,6 +267,12 @@ <groupId>dom4j</groupId> <artifactId>dom4j</artifactId> <version>1.6.1</version> <exclusions> <exclusion> <groupId>xml-apis</groupId> <artifactId>xml-apis</artifactId> </exclusion> </exclusions> </dependency> <!-- https://mvnrepository.com/artifact/javax.mail/mail --> @@ -359,12 +365,25 @@ <version>3.1.472</version> </dependency> </dependencies> <build> <finalName>utils</finalName> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <!--这部分可有可无,加上的话则直接生成可运行jar包--> <!--<archive>--> <!--<manifest>--> <!--<mainClass>${exec.mainClass}</mainClass>--> <!--</manifest>--> <!--</archive>--> <descriptor>src/main/resources/assembly.xml</descriptor> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> @@ -377,26 +396,6 @@ <skip>true</skip> </configuration> </plugin> <!--<plugin>--> <!--<groupId>org.apache.maven.plugins</groupId>--> <!--<artifactId>maven-assembly-plugin</artifactId>--> <!--<configuration>--> <!--<descriptorRefs>--> <!--<descriptorRef>jar-with-dependencies</descriptorRef>--> <!--</descriptorRefs>--> <!--</configuration>--> <!--<executions>--> <!--<execution>--> <!--<id>make-assembly</id>--> <!--<phase>package</phase>--> <!--<goals>--> <!--<goal>single</goal>--> <!--</goals>--> <!--</execution>--> <!--</executions>--> <!--</plugin>--> <plugin> <groupId>org.apache.maven.plugins</groupId> @@ -418,6 +417,8 @@ </execution> </executions> </plugin> </plugins> <resources> <resource> src/main/java/org/yeshi/utils/generater/GeneraterManagerV2.java
@@ -87,12 +87,13 @@ throw new Exception("尚未配置异常信息"); } String exceptionName = NameUtil.getDefaultExceptionName(config.getEntity()); String path = getDirPath(config.getService().getException().getPkg()); try { ExceptionVO vo = new ExceptionVO.Builder().setEntity(config.getEntity()).setPackageName(config.getService().getException().getPkg()).setBase(new ClassInfo(base.getSimpleName(), base.getName())).build(); String result = GeneraterUtil.createException(vo); //保存 saveFile(result, path); saveFile(result, new File(path, exceptionName + ".java").getAbsolutePath()); } catch (Exception e) { e.printStackTrace(); } @@ -218,6 +219,10 @@ } } if (config.getService().getException() != null) { createException(Exception.class); } QueryVO queryVO = createQuery(config.getService().getQueryPackage()); ClassInfo query = new ClassInfo(queryVO.getClassName(), queryVO.getPackageName() + "." + queryVO.getClassName()); src/main/java/org/yeshi/utils/generater/util/NameUtil.java
@@ -20,6 +20,10 @@ return entity.getSimpleName() + "Service"; } public static String getDefaultExceptionName(Class entity) { return entity.getSimpleName() + "Exception"; } public static String getDefaultQueryName(Class entity) { return entity.getSimpleName() + "Query"; } src/main/java/org/yeshi/utils/generater/vo/xmlconfig/XmlConfigParseUtil.java
@@ -3,7 +3,6 @@ import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; import org.yeshi.utils.generater.GeneraterManagerV2; import org.yeshi.utils.generater.annotation.admin.DaoQueryCondition; import org.yeshi.utils.generater.annotation.admin.Show; @@ -21,8 +20,9 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import java.io.*; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -36,7 +36,7 @@ */ public class XmlConfigParseUtil { public static GenertorConfig parse(InputStream inputStream) throws IOException, ParserConfigurationException, SAXException, ClassNotFoundException { public static GenertorConfig parse(InputStream inputStream) throws Exception { if (inputStream == null) { throw new FileNotFoundException(); } @@ -45,6 +45,9 @@ DocumentBuilder builder = factory.newDocumentBuilder(); Document root = builder.parse(inputStream); NodeList nodelist = root.getElementsByTagName("generator-config"); if (nodelist.getLength() == 0) { throw new Exception("xml格式错误"); } Node rootNode = nodelist.item(0); String clazz = rootNode.getAttributes().getNamedItem("class").getNodeValue(); genertorConfig.setEntity(Class.forName(clazz)); src/main/resources/assembly.xml
New file @@ -0,0 +1,34 @@ <assembly> <id>full</id> <formats> <format>jar</format> </formats> <includeBaseDirectory>false</includeBaseDirectory> <dependencySets> <dependencySet> <unpack>true</unpack> <scope>runtime</scope> <outputDirectory></outputDirectory> <!--<excludes>--> <!--<exclude>org.yeshi:utils</exclude>--> <!--</excludes>--> </dependencySet> </dependencySets> <!--<fileSets>--> <!--<fileSet>--> <!--<includes>--> <!--<include>target/classes/**</include>--> <!--</includes>--> <!--<outputDirectory></outputDirectory>--> <!--</fileSet>--> <!--</fileSets>--> </assembly>