Java Spring Maven 清理错误 - 请求的配置文件“pom.xml”无法激活,因为它不存在
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28192761/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Spring Maven clean error - The requested profile "pom.xml" could not be activated because it does not exist
提问by Rodney Nogueira
I'm trying to build a Spring-Boot *.war with maven, but I keep getting:
我正在尝试使用 maven 构建 Spring-Boot *.war,但我不断收到:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.600 s
[INFO] Finished at: 2015-01-28T10:46:11-03:00
[INFO] Final Memory: 6M/123M
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "pom.xml" could not be activated because it does not exist.
After running the mvn: clean.
运行 mvn 后:干净。
I have no idea why, I'm following this guide.
我不知道为什么,我正在遵循本指南。
My pom.xml
我的 pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.bigriver</groupId>
<artifactId>webconsultas</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>WebConsultas</name>
<description>Sistema de consulta m?dica on the web</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<start-class>demo.WebConsultasApplication</start-class>
<java.version>1.8</java.version>
</properties>
<dependencies>
<!--
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!--
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<scope>runtime</scope>
</dependency>
-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-cypher-compiler-2.1</artifactId>
<version>2.1.5</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>http://repo.spring.io/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>http://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
</project>
After the success, maven generates a target folder in the project, it's containing only the Manifest.mf, pom.properties and pom.xml.
成功后maven在项目中生成一个target文件夹,里面只包含Manifest.mf、pom.properties和pom.xml。
I'm a beginner using maven/spring and I haven't find any clues about what it might be. Any help would be appreciated.
我是使用 maven/spring 的初学者,我没有找到任何关于它可能是什么的线索。任何帮助,将不胜感激。
The complete log:
完整的日志:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project webconsultas: Fatal error compiling: invalid target release: 1.8 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project webconsultas: Fatal error compiling
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:108)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Fatal error compiling
at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:796)
at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:133)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19 more
Caused by: org.codehaus.plexus.compiler.CompilerException: invalid target release: 1.8
at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:191)
at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:169)
at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:785)
... 22 more
Caused by: java.lang.IllegalArgumentException: invalid target release: 1.8
at com.sun.tools.javac.main.RecognizedOptions$GrumpyHelper.error(RecognizedOptions.java:88)
at com.sun.tools.javac.main.RecognizedOptions.process(RecognizedOptions.java:359)
at com.sun.tools.javac.api.JavacTool.processOptions(JavacTool.java:242)
at com.sun.tools.javac.api.JavacTool.getTask(JavacTool.java:199)
at com.sun.tools.javac.api.JavacTool.getTask(JavacTool.java:68)
at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:115)
... 24 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
采纳答案by Aaron Digulla
The warning message
警告信息
[WARNING] The requested profile "pom.xml" could not be activated because it does not exist.
means that you somehow passed -P pom.xml
to Maven which means "there is a profile called pom.xml
; find it and activate it". Check your environment and your settings.xml
for this flag and also look at all <profile>
elements inside the various XML files.
意味着您以某种方式传递-P pom.xml
给 Maven,这意味着“有一个名为 的配置文件pom.xml
;找到它并激活它”。检查您的环境和您settings.xml
的此标志,并查看<profile>
各种 XML 文件中的所有元素。
Usually, mvn help:effective-pom
is also useful to see what the real POM would look like.
通常,mvn help:effective-pom
查看真实 POM 的外观也很有用。
Now the error means that you tried to configure Maven to build Java 8 code but you're not using a Java 8 runtime. Solutions:
现在错误意味着您尝试配置 Maven 以构建 Java 8 代码,但您没有使用 Java 8 运行时。解决方案:
- Install Java 8
- Make sure Maven uses Java 8 if you have it installed.
JAVA_HOME
is your friend - Configure the Java compiler in your
pom.xml
to a Java version which you actually have.
- 安装 Java 8
- 如果已安装,请确保 Maven 使用 Java 8。
JAVA_HOME
是你的朋友 - 将您的 Java 编译器配置为
pom.xml
您实际拥有的 Java 版本。
Related:
有关的:
回答by Abhijeet
回答by mantri
I was getting this same warning everytime I was doing 'maven clean'. I found the solution :
每次我在做 'maven clean' 时,我都会收到同样的警告。我找到了解决方案:
Step - 1Right click on your project in Eclipse
Step - 2Click Properties
Step - 3Select Maven in the left hand side list.
Step - 4You will notice "pom.xml" in the Active Maven Profiles text box on the right hand side. Clear it and click Apply.
步骤 - 1在 Eclipse 中右键单击您的项目
步骤 - 2单击属性
步骤 - 3在左侧列表中选择 Maven。
步骤 - 4您会在右侧的 Active Maven Profiles 文本框中注意到“pom.xml”。清除它并单击应用。
Below is the screen shot :
以下是屏幕截图:
Hope this helps. :)
希望这可以帮助。:)
回答by Pranav
Yes even I got the same error. So I did the following changes
是的,即使我也遇到了同样的错误。所以我做了以下更改
-> Check the error in the Problems tab located near the Console tab
-> 检查位于控制台选项卡附近的问题选项卡中的错误
-> See where the error persists, Its possible that some jar file may be corrupted or is outdated so, pom isn't activated in the Project.
-> 查看错误仍然存在的地方,可能是某些 jar 文件可能已损坏或已过时,因此项目中未激活 pom。
-> I found one of my jar was outdated version so I updated it by getting the dependencies from maven repository from this link https://mvnrepository.com
-> 我发现我的一个 jar 版本已过时,因此我通过从此链接https://mvnrepository.com获取 maven 存储库中的依赖项来更新它
So to conclude, do check where the error persist and which jar file is outdated and make changes accordingly
所以总而言之,请检查错误持续存在的位置以及哪个 jar 文件已过时并进行相应的更改
回答by rex roy
Goto Properties -> maven Remove the pom.xml from the activate profiles and follow the below steps.
转到 Properties -> maven 从激活配置文件中删除 pom.xml 并按照以下步骤操作。
Steps :
脚步 :
- Delete the .m2 repository
- Restart the Eclipse IDE
- Refresh and Rebuild it
- 删除 .m2 存储库
- 重新启动 Eclipse IDE
- 刷新并重建它
回答by Nagaraja JB
Bumped into same warning. If you specified goals and built project using "Run as -> Maven build..." option check and remove pom.xmlfrom Profiles:just below Goals:
遇到同样的警告。如果您指定目标并使用“ Run as -> Maven build...”选项检查并从Profiles 中删除pom.xml构建项目:就在目标下方: