我正在关注一个很棒的教程: http://www.objectdb.com/tutorial/jpa/eclipse/spring/project
在复制pom.xml的代码后的第一步,我得到9个错误.这是我的pom.xml第1行显示的错误:
Failure to transfer org.apache.maven.reporting:maven-reporting-api:jar:2.0.6 from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven.reporting:maven-reporting-api:jar:2.0.6 from/to central (http://repo.maven.apache.org/maven2): The operation was cancelled. pom.xml /Guestbook line 1 Maven Configuration Problem
Run Code Online (Sandbox Code Playgroud)
如有必要,我可以发布其他错误.我之前尝试过运行一些简单的预制maven项目,我相信他们称之为archtypes.他们有类似的错误.我不明白为什么会这样,我不能得到一些你好世界的东西不立即抛出错误.
我正在将项目迁移Jboss 5.1
到jboss 7.1
我有两个EAR,运行在同一个Jboss上.它们包含内部的ejb项目,并且services.jar
由于finalname
标记而调用了两个ejb jar文件 EJB_PROJECT/pom.xml
<build>
<finalName>services</finalName>
.....
</build>
Run Code Online (Sandbox Code Playgroud)
在Jboss 5.1上它工作正常,但现在我得到错误:
18:07:16,858 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-7) MSC00001: Failed to start service jboss.deployment.subunit."my1.ear"."services.jar".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.subunit."my1.ear"."services.jar".INSTALL: Failed to process phase INSTALL of subdeployment "services.jar" of deployment "my1.ear"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.7.0_45]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.7.0_45]
at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_45]
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS018027: Failed to add JBoss Web deployment service
at …
Run Code Online (Sandbox Code Playgroud) 我在Java Maven项目中工作..bat
项目的根目录中有一个文件调用Java类,其中包含一些类似这样的参数:
java my.package.MyClass abc hi 1
Run Code Online (Sandbox Code Playgroud)
现在,当我这样做时,我的项目jar就构建在该项目的目标目录中mvn clean install
.当我运行该.bat
文件时,它给出了以下错误
Error: Could not find or load main class my.package.MyClass
Run Code Online (Sandbox Code Playgroud)
Project pom.xml
仅包含jar作为依赖项.
有人可以帮我解决这个问题.我需要做些什么pom.xml
才能让它发挥作用.
task writeNewPom {
pom {
project {
/*
build {
plugins {
plugin {
groupId 'GROUP_ID'
artifactId 'maven-ipcentral-plugin'
version '4.7'
executions {}
configuration {
url "http://CENTRAL_REPORTING_SERVER"
logfileprefix "test"
ipcProject = true
businessUnit "FOUR_DIGIT_CODE"
componentEditorsGrouper "ccp-dev"
assetEditorsGrouper "ccp-dev"
username "USERNAME"
}
}
}
}
*/
pluginRepositories {
pluginRepository {
id 'ipcentral-snapshots'
name 'IPCentral Snapshot Repository'
url 'http://PLUGIN_SOURCE/'
snapshots {
enabled = false
}
releases {
enabled = true
}
}
}
profiles {
profile {
id 'inject-cec-credentials'
activation {
activeByDefault = …
Run Code Online (Sandbox Code Playgroud) 我正在使用 Properties Maven Plugin 来读取一些属性,在执行这个插件后我执行另一个插件,之后我想用不同的配置再次执行这个插件
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>src/Args.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
执行 maven-antrun-plugin 然后用配置“src/Args2.properties”调用这个插件,因为最后一个插件我声明了一个新的属性,它在文件“Args2.properties”中使用
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<taskdef resource="net/sf/antcontrib/antcontrib.properties"
classpathref="maven.plugin.classpath"/>
<if>
<equals arg1="${serviceType}" arg2="none"/>
<then>
<property name="prop" value="x"/>
</then>
<else>
<property name="prop"value="y"/>
</else>
</if>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
和 Args2.properties :
prop2=${prop}/anotherValue
Run Code Online (Sandbox Code Playgroud)
我想在 Antrun 插件中给 prop 一个值后,稍后从文件 Args2 中读取 prop2
目前我有一个项目,它使用swagger-codegen-maven-plugin
生成带有delegatePattern
.
pom.xml
:
[...]
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>generate-api-v1</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/specs/v1.yaml</inputSpec>
<language>spring</language>
<apiPackage>test.foo.bar.v1</apiPackage>
<modelPackage>test.foo.bar.v1.v1.model</modelPackage>
<generateSupportingFiles>false</generateSupportingFiles>
<configOptions>
<java8>true</java8>
<dateLibrary>java8</dateLibrary>
<delegatePattern>true</delegatePattern>
<useOptional>true</useOptional>
<useBeanValidation>true</useBeanValidation>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
[...]
Run Code Online (Sandbox Code Playgroud)
目前它生成这样的控制器接口:
public interface FooApi {
FooDelegate getDelegate();
@ApiOperation(value = "", nickname = "fooAction", notes = "", response = String.class)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Success", response = String.class)
})
@RequestMapping(value = "/fooAction",
produces = { "text/plain" },
method = RequestMethod.GET) …
Run Code Online (Sandbox Code Playgroud) 我正在使用Spring starter项目在STS中建立一个项目,并添加了必需的依赖项,例如Spring Security和JSP。但是pom文件的第一行抛出错误,未知
有人可以帮我解决这个问题吗?
我正在使用STS 4
<?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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>RememberMeApp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>RememberMeApp</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</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-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-mavenplugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Run Code Online (Sandbox Code Playgroud)
通常这应该可以正常工作
有人可以解释一下这个依赖项在依赖项管理下的作用以及添加它后为什么我们不需要提及依赖项的版本吗?
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud) dependencies dependency-management pom.xml maven spring-boot
我正在尝试学习 Spring Boot 实践,并使用我的 IntelliJ IDE 通过 Spring Starter 导入基本 Spring Boot 应用程序的样板,但 Maven 无法解析所有依赖项,并且我的项目错过了重要的依赖项。我不明白这是什么原因。
首先,我认为问题出在使用 JDK8 作为较新版本的 SpringFramework,然后我安装了 JDK11,但同样的问题仍然存在,据我所知 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.selfspring</groupId>
<artifactId>conference-demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>conference-demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin> …
Run Code Online (Sandbox Code Playgroud) 你好.我有一个JavaSpring MVC应用程序.我正在尝试使用spring mvc和mongodb数据库以及apache maven.但是我的pom.xml文件有问题.这是我的pom.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<project xmln.s="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>finartzProject</groupId>
<artifactId>FinartzProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<!-- spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>4.0.6.RELEASE</version>
</dependency>
<!-- jstl -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- javax servlet -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<!-- mongodb -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>1.6.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.4.0</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warSourceDirectory>src/main/webapp</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin> …
Run Code Online (Sandbox Code Playgroud)我们正在使用 Maven 项目,需要检查我们在 java 应用程序中使用的是 log4j 或 log4j2。请指导我下面的最佳实践
是我的 pom.xml
<properties>
<!-- Avoid warnings about platform encoding -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<powermock.version>1.6.2</powermock.version>
<log4j.version>2.3</log4j.version>
</properties><dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j.version}</version>
</dependency><dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId>
<version>${log4j.version}</version>
</dependency>
</project>
Run Code Online (Sandbox Code Playgroud)