Keyboard Shortcuts
ctrl + shift + ? :
Show all keyboard shortcuts
ctrl + g :
Navigate to a group
ctrl + shift + f :
Find
ctrl + / :
Quick actions
esc to dismiss
Likes
Search
how to get code generation to put code in specific package?
Hello Everyone!
I hope everyone is having a great New Year and lots of Java is planned! I have a Maven project using xmlbean. How is it that I can get it to put the generated sources into a specific package? By default, the generated sources go into `org.apache.xmlbeans.samples.xquery`. I would like them to go into a base package `com.example`. ``` $ mvn clean generate-sources compile ``` and if you want to run it. ``` $ mvn exec:java ``` I attached the sample project. ``` <plugins> <plugin> <groupId>org.apache.xmlbeans</groupId> <artifactId>xmlbeans</artifactId> <version>5.3.0</version> <executions> <execution> <goals> <goal>compile</goal> </goals> </execution> </executions> <configuration> <partialMethods>ALL,-GET_LIST,-XGET_LIST,-XGET_ARRAY</partialMethods> <extensions> </extensions> </configuration> <dependencies> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> <version>2.23.1</version> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-api</artifactId> <version>2.23.1</version> </dependency> </dependencies> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.4.0</version> <configuration> <mainClass>xmlbean01.LoadXml</mainClass> </configuration> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>1.9</version> <executions> <execution> <id>add-source</id> <phase>generate-sources</phase> <goals> <goal>add-source</goal> </goals> <configuration> <sources> <source> ${project.build.directory}/generated-sources </source> </sources> </configuration> </execution> </executions> </plugin> ``` -- Brian Lavender "There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies." Professor C. A. R. Hoare The 1980 Turing award lecture |
It turns out if I just change the namespace in the schema and the xml
toggle quoted message
Show quoted text
document, the generated code will match the package name to the same as the namespace! employeesshema.xsd ``` <xs:schema xmlns:xs=" elementFormDefault="qualified" targetNamespace=" xmlns="> ``` and `employess.xml` ``` <employees xmlns="> <employee> <name>Fred Jones</name> ``` On Tue, Jan 21, 2025 at 03:15:43PM -0800, Brian E. Lavender wrote:
Hello Everyone! --
Brian Lavender "There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies." Professor C. A. R. Hoare The 1980 Turing award lecture |
to navigate to use esc to dismiss