Maven does not create persistence.xml file

I am reading this article on the maven project web page, which lists various directory layouts (for example: 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 is not created. This is important to me because I would like to get "persistence.xml" which is in this directory.

Should I add a parameter to the mvn command? How can I automatically generate "src / main / resources" that contains the META-INF / persistence.xml file?

Thanks, Relationship

+5
source share
3 answers

The problem is that the following command (...) does not create the src / main / resources / META-INF directory. This is important to me because I would like to get "persistence.xml" which is in this directory.

The maven quick launch archetype does not create src/main/resourcesand src/test/resources. There are several explanations:

  • As indicated by its name, this archetype allows you to quickly launch a project, but you need to form it.
  • Why src/main/resourcesdoes this archetype create and not, say src/main/assembly,?
  • Creating empty directories is actually not possible for a long time (see ARCHETYPE-57 ).

, src/main/resources/META-INF/persistence.xml , .

mvn? "src/main/resources", META-INF/persistence.xml?

- , .

JPA:

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

JPA:

$ 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
+8

, maven -. , . , .

+3

Here you used the quickstart archetype, which is an example, more details here . If you want the standard Java EE layout, you use the maven-archetype-j2ee-simplearchetype:

mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-j2ee-simple -DinteractiveMode=false
+1
source

All Articles