-
Notifications
You must be signed in to change notification settings - Fork 26
Code Generator
zzg edited this page Mar 31, 2017
·
39 revisions
@DB(url="jdbc:mysql://127.0.0.1:3306/test",username="root", password="root")
public interface TestDB {
public static DBConfig DB=DBConfig.fromClass(TestDB.class);
public static class Generate{
public static void main(String[] args) {
//Generate Model classes to directory: src/main/java OR src
DBModelGenerateMain.generateModelClass(TestDB.class);
}
}
}
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<annotationProcessors>
<annotationProcessor>
com.tsc9526.monalisa.orm.processor.DBAnnotationProcessor
</annotationProcessor>
</annotationProcessors>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>compile</phase>
<goals>
goal>copy-resources</goal>
</goals>
<configuration>
<encoding>UTF-8</encoding>
<outputDirectory>${basedir}/target/classes</outputDirectory>
<resources>
<resource>
<directory>target/generated-sources/annotations</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
<filtering>false</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
OR
- Download plugin ,Place the jar to : eclipse/plugins
- Restart Eclipse
-
Need to set up project(Properties->Java Compiler)
JDK compliance: >= 1.6
-
Need to set up project(Properties->Java Compiler->Annotation Processing)
Enable this option: Enable annotation processing
Like this:
-
Need to set up eclipse (Window->Preferences->Java->Editor->Save Action -> Configure -> monalisa)
Enable this option: @Select
Like this:
Plugin installed, you can write multiline strings. For detail: Multiline Syntax
Effect as shown below: