Maven Java EE Configuration

In my maven project, I have this efficient POM:

<?xml version="1.0"?> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <groupId>spring</groupId> <artifactId>example</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>war</packaging> <name>example</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>4.0.3.RELEASE</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework.ws</groupId> <artifactId>spring-ws-core</artifactId> <version>2.1.4.RELEASE</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-web</artifactId> <version>3.2.3.RELEASE</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-config</artifactId> <version>3.2.3.RELEASE</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>4.3.5.Final</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> <version>5.1.0.Final</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>4.0.3.RELEASE</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>4.0.3.RELEASE</version> <scope>compile</scope> </dependency> </dependencies> <repositories> <repository> <snapshots> <enabled>false</enabled> </snapshots> <id>central</id> <name>Central Repository</name> <url>http://repo.maven.apache.org/maven2</url> </repository> </repositories> <pluginRepositories> <pluginRepository> <releases> <updatePolicy>never</updatePolicy> </releases> <snapshots> <enabled>false</enabled> </snapshots> <id>central</id> <name>Central Repository</name> <url>http://repo.maven.apache.org/maven2</url> </pluginRepository> </pluginRepositories> <build> <sourceDirectory>C:\Users\Kleber\Downloads\Projetos\example\src\main\java</sourceDirectory> <scriptSourceDirectory>C:\Users\Kleber\Downloads\Projetos\example\src\main\scripts</scriptSourceDirectory> <testSourceDirectory>C:\Users\Kleber\Downloads\Projetos\example\src\test\java</testSourceDirectory> <outputDirectory>C:\Users\Kleber\Downloads\Projetos\example\target\classes</outputDirectory> <testOutputDirectory>C:\Users\Kleber\Downloads\Projetos\example\target\test-classes</testOutputDirectory> <resources> <resource> <directory>C:\Users\Kleber\Downloads\Projetos\example\src\main\resources</directory> </resource> </resources> <testResources> <testResource> <directory>C:\Users\Kleber\Downloads\Projetos\example\src\test\resources</directory> </testResource> </testResources> <directory>C:\Users\Kleber\Downloads\Projetos\example\target</directory> <finalName>example-0.0.1-SNAPSHOT</finalName> <pluginManagement> <plugins> <plugin> <artifactId>maven-antrun-plugin</artifactId> <version>1.3</version> </plugin> <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>2.2-beta-5</version> </plugin> <plugin> <artifactId>maven-dependency-plugin</artifactId> <version>2.1</version> </plugin> <plugin> <artifactId>maven-release-plugin</artifactId> <version>2.0</version> </plugin> </plugins> </pluginManagement> <plugins> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> <configuration> <url>http://localhost:8080/manager/text</url> <server>TomcatServer</server> <path>/webappExample</path> <username>user001</username> <password>123</password> </configuration> </plugin> <plugin> <artifactId>maven-clean-plugin</artifactId> <version>2.4.1</version> <executions> <execution> <id>default-clean</id> <phase>clean</phase> <goals> <goal>clean</goal> </goals> </execution> </executions> </plugin> <plugin> <artifactId>maven-install-plugin</artifactId> <version>2.3.1</version> <executions> <execution> <id>default-install</id> <phase>install</phase> <goals> <goal>install</goal> </goals> </execution> </executions> </plugin> <plugin> <artifactId>maven-resources-plugin</artifactId> <version>2.5</version> <executions> <execution> <id>default-resources</id> <phase>process-resources</phase> <goals> <goal>resources</goal> </goals> </execution> <execution> <id>default-testResources</id> <phase>process-test-resources</phase> <goals> <goal>testResources</goal> </goals> </execution> </executions> </plugin> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.10</version> <executions> <execution> <id>default-test</id> <phase>test</phase> <goals> <goal>test</goal> </goals> </execution> </executions> </plugin> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <executions> <execution> <id>default-testCompile</id> <phase>test-compile</phase> <goals> <goal>testCompile</goal> </goals> </execution> <execution> <id>default-compile</id> <phase>compile</phase> <goals> <goal>compile</goal> </goals> </execution> </executions> </plugin> <plugin> <artifactId>maven-war-plugin</artifactId> <version>2.1.1</version> <executions> <execution> <id>default-war</id> <phase>package</phase> <goals> <goal>war</goal> </goals> </execution> </executions> </plugin> <plugin> <artifactId>maven-deploy-plugin</artifactId> <version>2.7</version> <executions> <execution> <id>default-deploy</id> <phase>deploy</phase> <goals> <goal>deploy</goal> </goals> </execution> </executions> </plugin> <plugin> <artifactId>maven-site-plugin</artifactId> <version>3.0</version> <executions> <execution> <id>default-site</id> <phase>site</phase> <goals> <goal>site</goal> </goals> <configuration> <outputDirectory>C:\Users\Kleber\Downloads\Projetos\example\target\site</outputDirectory> <reportPlugins> <reportPlugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-project-info-reports-plugin</artifactId> </reportPlugin> </reportPlugins> </configuration> </execution> <execution> <id>default-deploy</id> <phase>site-deploy</phase> <goals> <goal>deploy</goal> </goals> <configuration> <outputDirectory>C:\Users\Kleber\Downloads\Projetos\example\target\site</outputDirectory> <reportPlugins> <reportPlugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-project-info-reports-plugin</artifactId> </reportPlugin> </reportPlugins> </configuration> </execution> </executions> <configuration> <outputDirectory>C:\Users\Kleber\Downloads\Projetos\example\target\site</outputDirectory> <reportPlugins> <reportPlugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-project-info-reports-plugin</artifactId> </reportPlugin> </reportPlugins> </configuration> </plugin> </plugins> </build> <reporting> <outputDirectory>C:\Users\Kleber\Downloads\Projetos\example\target\site</outputDirectory> </reporting> </project> 

At this point, the Markers tab on my Eclipse IDE displays this error:

 Description Resource Path Location Type Dynamic Web Module 3.0 requires Java 1.6 or newer. example line 1 Maven Java EE Configuration Problem One or more constraints have not been satisfied. example line 1 Maven Java EE Configuration Problem 

I am trying to fix this configuration in the build path from my project (in the properties / Java build path), but when I run Maven> Update Project, the value for this parameter goes back to the previous one.

Where should I change this setting to fix this error?

+18
source share
12 answers
  1. Go to the Build Path project and change the Java library version to 1.7
  2. Go to Eclipse Settings -> Java -> Compiler -> Change compliance level to 1.7
  3. Right click on the project -> Properties -> Project Facets
  4. Uncheck the Dynamic Web Module checkbox and click Apply (also uncheck the JavaServer Faces checkbox if you have one)
  5. Change the Java version of the facet to 1.7 and click Apply.
  6. Add Dyanmic Web Module v3.0 , apply.

Eclipse face configuration contains errors. Make sure you keep clicking Apply between checking and unchecking the faces.

References:

Can't change the version of the Dynamic Web Module project facet to 3.0? Change Dynamic Web Module project aspect version to 2.5
+43
source

GGrec solution does not work for me. I was able to fix this problem by adding the following to pom.xml:

 <build> <finalName>finalName</finalName> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.8</source> <!-- yours Java version --> <target>1.8</target> <!-- yours Java version --> </configuration> </plugin> </plugins> </build> 

UPDATE: In addition, I realized that every time you run the mvn install command on this pom.xml, it overrides the previous configuration. The correct solution is to either remove this version from pom.xml, or install it in eclipse settings, or simply use the configuration from pom.xml.

+28
source

After completing the troubleshooting steps above. Update the maven project.

Right click on your project -> Maven -> Update Project

Or just Alt + f5.

Hope this can help someone.

+7
source

Just like Kefas, I specify the java version before 1.7, and it works!

  <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> 
+4
source

The above suggestions are useful to me! Right-click on the project -> Properties -> Project Boundaries, then change the Java facet version to 1.7.

If this does not work, add the following code to pom.xml:

 <build> <finalName>finalName</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.7</source> <!-- yours Java version --> <target>1.7</target> <!-- yours Java version --> </configuration> </plugin> </plugins> </build> 

Save pom.xml.

Then right click on the project -> Maven -> Update Project.

+2
source

This may seem silly, but I just did Project-> Clean and then Maven-> Update.

Solved a problem.

+1
source

I am using java 1.8. The following actions have been fixed.

Remove from pom:

 <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.5.1</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> 

He will complain that pom is not updating. The quick fix used is for updating, then you get a whole bunch of errors.

RE-ADD to pom:

 <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.5.1</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> 

Updated maven and all errors are cleared.

0
source

This works for me:

 <build> <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.3</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.6</version> <configuration> <warSourceDirectory>src/main/webapp</warSourceDirectory> <warName>mfp</warName> <failOnMissingWebXml>false</failOnMissingWebXml> </configuration> </plugin> </plugins> </pluginManagement> <finalName>myprojectname</finalName> </build> 
0
source

Changed version to 3.1 and tags and to 1.7

  <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> 

0
source

I had to reset the maven settings in Window-> "Settings" → Maven-> "User Settings" in "C: \ Development \ apache- Maven- 3.5.3 \ conf \ settings.xml".

0
source

The correct answer is: - A simple thing. In most cases, you cannot change the version of Dynamic Web Module to 3.0. By default it should be 2.3 or 2.4 or another. This will not work, right click on project-> preference → project facet → uncheck the dynamic web module and change the version to 3.0, then check it. and I think you should change the latest version (i.e.: 1.7 or higher) that. After that, click the "Apply" and "Close" buttons.

then update the maven project. right click on project, select maven -> update project. anyway, the error will continue for 80% of us ..

The real solution is here 1> go to the workspace folder 2> then go to your project folder 3> check for the presence of the .settings file (sometimes it can be hidden and then hide it .. (such a rare chance) 4> Go into it. Then in the settings file, check the org.eclipse.wst.common.project.facet.core.xml file and edit it with notepad ++ or something like that.enter code here 5> this is the code inside

 <?xml version="1.0" encoding="UTF-8"?> <faceted-project> <fixed facet="wst.jsdt.web"/> <installed facet="java" version="1.5"/> <installed facet="jst.web" version="2.4"/> <installed facet="wst.jsdt.web" version="1.0"/> </faceted-project> 

change jst.web version to 3.0 like this

 <?xml version="1.0" encoding="UTF-8"?> <faceted-project> <fixed facet="wst.jsdt.web"/> <installed facet="java" version="1.5"/> <installed facet="jst.web" version="3.0"/> <installed facet="wst.jsdt.web" version="1.0"/> </faceted-project> 

then finally upgrade maven .. then restart eclipse or other IDE

0
source

I added below line of code in pom.xml and it worked.

 <properties> <maven-jar-plugin.version>3.1.1</maven-jar-plugin.version> </properties> 
0
source

Source: https://habr.com/ru/post/920485/


All Articles