Page tree
Skip to end of metadata
Go to start of metadata

About the AppFuse Maven Plugin (AMP)

This plugin currently does two things:

For more documentation on this plugin, see its Maven-generated site.

Generating CRUD with AMP

Stop and think before generating code!


At first, I didn't want to add a code-generation feature like this because you end up with a 1-to-1 relationship between tables/pojos, DAOs and Managers. On most of my projects, I have far fewer DAOs and Managers than POJOs.

Using this plugin, you can run the following command to generate CRUD screens/classes for a POJO:

Package Names


The default package name is ${groupId}.model.Name. If you want to generate your code in a sub-package, specify a full package name like -Dentity=com.myproject.subpackage.model.Name or -Dentity=~.subpackage.model.Name. The tilde is a shortcut for ${groupId}.

If you don't specify the entity name, you're prompted for it. After generating the code, the plugin will install it for you as well, unless you specify -DdisableInstallation=true. If you disable installation, you can install it using:

To remove the installed artifacts, use:

If your entity is not defined in hibernate.cfg.xml, it will be added. In a modular project, these commands must be run in the "core" and "web" modules. The plugin is smart enough to figure out when it should/should not generate stuff based on the packaging type (jar vs. war).

There's also a goal that allows you to generate model objects from database tables:

Once you've generated and installed the POJO, you can generated crud for it using the appfuse:gen command.

Foreign Keys


If you have tables with foreign key it's necessary to alter the template src/test/resources/appfuse/model/Ejb3PropertyGetAnnotation.ftl

        <#lt/>${pojo.generateJoinColumnsAnnotation(property, cfg)} instead of


to generate @ManyToOne anotations 

(It's necessary to do mvn appfuse:copy-templates first)

Don't forget to change this to read the identifier field from the other pojo 

    <form:select ...  itemLabel="label" itemValue="value" >

in your WEB-INF/pages/entityform.jsp

By default the generated code makes use of the GenericDao and GenericManager. If you do not want this add this to your pom file:

Customizing AMP Templates

The FreeMarker templates that AMP uses to generate code are packaged in the plugin itself. Since version 2.0.2, you can copy the code generation templates into your project using the following command:

Installing AppFuse's source into your project

The good news is creating an "old style" project is now pretty easy. If you create a new project using 2.0-m5+, you can now use:

This goal will convert your project to use all of AppFuse's source and remove all dependencies on AppFuse. It will also refactor all package names and directories to match your project's groupId.

What the full-source plugin does:

  1. Exports all sources from Subversion into your project. It reads the dao.framework and web.framework properties to determine what you need.
  2. Removes warpath plugin from pom.xml.
  3. Calculates dependencies by reading pom.xml files form the various AppFuse modules. It replaces your dependencies with these new ones. The order of the dependencies added is alphabetical based on groupId.
  4. Reads properties from the root AppFuse pom.xml and adds the ones that don't exist to your project.
  5. Renames packages to match your project's groupId.
  • No labels