I read this article on the maven project web page that lists the different directory layouts (like: src/main/resources which is for Application/Library resources).
The problem is that when I run the following command (found here):
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
the src/main/resources/META-INF directory isn't created. It's important for me because I'd like to reach the "persistence.xml" that is found in that directory.
Should I add an option in the mvn command? How can I automatically generate the "src/main/resources" that contains the "META-INF/persistence.xml" file?
Thank you, Regards
The problem is that when I run the following command (...) the src/main/resources/META-INF directory isn't created. It's important for me because I'd like to reach the "persistence.xml" that is found in that directory.
The maven quickstart archetype does NOT create src/main/resources
nor src/test/resources
. There are several explanations:
src/main/resources
and not, say, src/main/assembly
?In other words, just add src/main/resources/META-INF/persistence.xml
manually if you use this archetype.
Should I add an option in the mvn command? How can I automatically generate the "src/main/resources" that contains the "META-INF/persistence.xml" file?
You can't with this archetype - and I don't really understand why this is a such big issue.
There is a JPA archetype though:
mvn archetype:create \ -DgroupId=com.mycompany.project \ -DartifactId=my-project-domain \ -DpackageName=com.company.project.domain \ -DarchetypeGroupId=com.rfc.maven.archetypes \ -DarchetypeArtifactId=jpa-maven-archetype \ -DarchetypeVersion=1.0.0 \ -DremoteRepositories=http://maven.rodcoffin.com/repo
That creates the following bootstrap JPA project:
$ tree my-project-domain/ my-project-domain/ ├── pom.xml └── src ├── main │ ├── java │ │ └── com │ │ └── company │ │ └── project │ │ └── domain │ │ └── User.java │ └── resources │ └── META-INF │ └── persistence.xml └── test ├── java │ └── com │ └── company │ └── project │ └── domain │ ├── DbUnitDataLoader.java │ └── UserTest.java └── resources └── user.db.xml 16 directories, 6 files
Don't be too dependant on maven doing things for you. These archetypes are just there to provide basic templates. If they don't create a file for you, just go ahead and create it yourself.
Here you used the quickstart archetype which is the sample, more informations here.
If you want a Java EE standard layout you shoud use the maven-archetype-j2ee-simple
archetype :
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-j2ee-simple -DinteractiveMode=false
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With