I think we met the same problem, finally i resolved it with enlightening from this article
assuming you want to generate package com.company.base.dal.dao, we call com.company.base is root package, dal.dao is core package, then just put your template java file under src/main/java/dal/dao, and tweak the packaged="true"
in META-INF/maven/archetype-metadata.xml as below
<fileSet filtered="true" packaged="true" encoding="GBK"><!--packaged="true" tells maven to copy the core package in to root package while creating a project.-->
<directory>src/main/java</directory>
<includes>
<include>**/*.java</include>
</includes>
</fileSet>
say, if you set -Dpackage=com.alibaba.china
after execute mvn archetype:generate, it will create java source package as com/alibaba/china/dal/dao/sample.java
as how to give the prefix package information in sample.java, just use ${package} as below
package ${package}.dal.dao;
the archetype plugin will replace ${package} with -Dpackage as velocity template