我想把JDK tools.jar作为编译依赖项.我找到了一些示例,表明要使用systemPath属性,如下所示:
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
Run Code Online (Sandbox Code Playgroud)
问题是Mac OS X的路径不正确(但对Windows和Linux来说是正确的).对于它,正确的路径是$ {java.home} /../ Classes/classes.jar.
我正在寻找一种方法来定义maven属性,这样如果系统被检测为Mac Os X,则值设置为$ {java.home} /../ Classes/classes.jar,否则设置为$ {java.home} /../ lib/tools.jar(就像可以用ANT一样).有人有想法吗?
我使用struts2-archtype-starter在eclipse中创建了一个新的struts项目.
在做任何事情之前我的项目中已经出现了一些错误.解决了他们中的大多数,但有1仍然给我一些问题.
Missing artifact com.sun:tools:jar:1.5.0:system pom.xml
我试图手动将tools.jar添加到我的存储库,但这并没有解决问题.
我的pom看起来像这样
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.divespot</groupId>
<artifactId>website</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>E-Divespot diving community</name>
<url>http://www.e-divespot.com</url>
<description>A website to support divers from all around the world.</description>
<dependencies>
<!-- Junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<!-- Struts 2 -->
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.0.11.2</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-sitemesh-plugin</artifactId>
<version>2.0.11.2</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-spring-plugin</artifactId>
<version>2.0.11.2</version>
</dependency>
<!-- Servlet & Jsp -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version> …Run Code Online (Sandbox Code Playgroud) 我想我知道如何解决问题,除了:我不知道pom中特定版本的引用位置(我没有明确看到),我看到的解决方案是添加这个依赖:
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.6</version>
<scope>system</scope>
<systemPath>C:\Program Files\Java\jdk1.6.0_29\lib\tools.jar</systemPath>
</dependency>
Run Code Online (Sandbox Code Playgroud)
但我想使用com.oracle,Windows上的jdk目录是jdk1.8.
那么有没有办法让pom"想要"我在机器上实际拥有的工具版本?
我试图构建PlayN示例项目:
Missing artifact com.sun:tools:jar:1.6 pom.xml /playn-cute line 6 Maven Dependency Problem
Run Code Online (Sandbox Code Playgroud)
在每个pom.xml文件上.我该如何解决?
编辑:
我已将配置文件节点添加到pom.xml,但错误仍然存在.我已经检查过tools.jar它确实存在,而它没有.所以我已经添加tools.jar到lib文件夹了.仍然存在错误.
完整的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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.googlecode.playn</groupId>
<artifactId>playn-project</artifactId>
<version>1.0.1</version>
</parent>
<artifactId>playn-cute</artifactId>
<name>PlayN Cute Metaproject</name>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<playn.version>1.0.1</playn.version>
</properties>
<modules>
<module>core</module>
<module>java</module>
<module>html</module>
<!-- <module>flash</module> -->
<module>android</module>
</modules>
<profiles>
<profile>
<id>default-tools.jar</id>
<activation>
<property>
<name>java.vendor</name>
<value>Sun Microsystems Inc.</value>
</property>
</activation>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.6</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
</profile>
</profiles> …Run Code Online (Sandbox Code Playgroud) 我切换到Wildfly 8.1并且无法解决这个构建(路径)问题,这个问题最终会受到arquillian测试框架的影响.
pom.xml:
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<version.org.jboss.arquillian>1.1.5.Final</version.org.jboss.arquillian>
<version.org.wildfly>8.1.0.Final</version.org.wildfly>
<version.junit>4.11</version.junit>
</properties>
<profiles>
<profile>
<id>arquillian-jbossas-remote</id>
<dependencies>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-arquillian-container-remote</artifactId>
<version>${version.org.wildfly}</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
</profiles>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>${version.org.jboss.arquillian}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${version.junit}</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<version>3.1.4.GA</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.protocol</groupId>
<artifactId>arquillian-protocol-servlet</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration> …Run Code Online (Sandbox Code Playgroud) 我正在尝试通过这样做来使用 checkstyle 和 findbugsmvn checkstyle:checkstyle但我有这个错误
这个错误
[ERROR] Failed to execute goal on project my-project: Could not resolve dependencies for project default:my-project:jar:1.1: Could not find artifact com.sun:tools:jar:0 at specified path C:\Program Files\Java\jdk-11.0.2/../lib/tools.jar -> [Help 1]
Run Code Online (Sandbox Code Playgroud)
我的 JDK 中没有 tools.jar(我有 jdk-11.0.2)。
我从 2H 开始使用它,请帮助:/
我最近一直在研究自动化测试。
我现在熟悉了一些工具、框架、依赖项等,例如 Selenium、JUNits、TestNG,它们可以帮助我管理作为 QA 工程师的日常工作。
我经常使用 Selenium 和 TestNG 来构建我的解决方案,以及在最新 JDK 版本 (jdk-15.0.1) 上运行的 IntelliJ IDEA,该版本可在运行 macOs Catalina Version 10.15.7 的 Mac上使用。
我已经为我的项目配置了 mi POM.mxl 文件,从一开始它就在控制台上显示以下错误:
Cannot resolve com.sun:tools:0
我总是忽略这一点,因为我的 IDE 中的项目总是编译并运行,并且因为我从未使用过该依赖项。但现在我正尝试在 Mac 终端的 Maven 支持下运行我的项目,并且由于 sun:tools.jar 依赖项,我不允许编译迄今为止开发的任何工作项目。
我已经阅读了很多关于具有相同 sun:tools:jar 依赖项的类似问题的类似线程,如下所示:
我已经做了所有的事情,但是很多解决方案都是基于在jdk安装目录中找到tools.jar文件。由于我使用的是 JDK 15,因此该依赖项已被删除:
删除:rt.jar 和 tools.jar
以前存储在 lib/rt.jar、lib/tools.jar、lib/dt.jar 和各种其他内部 JAR 文件中的类和资源文件现在以更有效的格式存储在 lib 目录中的特定于实现的文件中。这些文件的格式未指定,如有更改,恕不另行通知。
我附上我在终端上收到的确切错误消息:
----------------------< org.example:YelpExercise >----------------------
[INFO] Building YelpExercise 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ------------------------------------------------------------------------ …Run Code Online (Sandbox Code Playgroud) 这是我的 pom.xml
<project ... >
<modelVersion>4.0.0</modelVersion>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-alexa</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<!-- lambda -->
<lambda.functionCode>${project.build.directory}/${project.build.finalName}.jar</lambda.functionCode>
<lambda.version>${project.version}</lambda.version>
<lambda.publish>true</lambda.publish>
<lambda.forceUpdate>true</lambda.forceUpdate>
<!-- versions -->
<alexa-skills-kit.version>1.3.1</alexa-skills-kit.version>
<junit.version>4.12</junit.version>
<kubernetes-client.version>2.5.1</kubernetes-client.version>
<sundrio.version>0.8.2</sundrio.version>
<!-- plugin versions -->
<lambda-maven-plugin.version>2.2.2</lambda-maven-plugin.version>
</properties>
<dependencyManagement>
<dependencies>
<!-- We are importing the kuberntes-client bom with deps to prevent jackson conflicts -->
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-client</artifactId>
<version>${kubernetes-client.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>openshift-client</artifactId>
<version>${kubernetes-client.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.amazon.alexa/alexa-skills-kit -->
Run Code Online (Sandbox Code Playgroud)
"pom.xml" 148L, 5831C
部署命令:
mvn clean package shade:shade com.github.seanroy:lambda-maven-plugin:deploy-lambda
部署 Maven 时出错:
日志: …