小编cod*_*het的帖子

基本的maven插件项目无法正常工作,Mojo插件描述符无法生成

我正在按照创建maven插件的教程,无法运行mvn install而不会出现错误.信息抱怨说,当注释应该为我生成时,我没有所需的mojo描述符.我正在运行maven 3.0.5并使用intellij作为我的ide.这是我的主要课程:

@Mojo(name = "modify-connector")
public class ComplianceMojo extends AbstractMojo {

    @Parameter
    private String artifactId;

    @Parameter
    private String version;

    @Override
    public void execute() throws MojoExecutionException, MojoFailureException {
        File jar = new File(getPluginContext().get("project.build.directory") + "/"
                + getPluginContext().get("project.build.finalname") + "/" + artifactId + "-" + version);
        if(jar.exists()){
            getLog().info("The file exists! " + jar.getAbsolutePath());
        } else {
            getLog().info("The file does not exist: " + jar.getAbsolutePath());
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我的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>mysql-jdbc-compliance-maven-plugin</groupId>
    <artifactId>mysql-jdbc-compliance-maven-plugin</artifactId> …
Run Code Online (Sandbox Code Playgroud)

java maven-plugin maven

63
推荐指数
5
解决办法
5万
查看次数

jenkins扩展参数插件groovy脚本

插件网站说您可以创建一个groovy脚本来运行以确定参数列表.

这怎么解决了?说明书没有说什么.

  1. 在什么上下文中运行脚本?
  2. 我应该从脚本中返回什么?
  3. 什么目录是脚本的cwd?它是环境变量WORKSPACE吗?
  4. 有一个额外的字段叫做variable bindings.这是怎么用的?

groovy jenkins

27
推荐指数
1
解决办法
2万
查看次数

EnableAutoConfiguration spring注释如何工作?

我不喜欢粗略的抽象,我认为Spring已经犯下了重大的重罪.

但是如果有人可以解释"自动"配置背后的算法,我愿意忽略它.

看看spring自己的javadocs,除了说它会智能地猜测你需要什么以及有关条件bean的事情之外,它并没有给予太大的帮助.

有人知道用什么算法来确定需要加载的内容吗?

java spring spring-boot

23
推荐指数
2
解决办法
2万
查看次数

查找类以递归方式扩展或实现的所有类和接口

我想知道是否有一种简单的方法来确定Java类以递归方式扩展或实现的完整类型列表?

例如:

class Foo extends Bar implements I1, I2 {...}
class Bar implements I3 {...}
interface I1 extends I4, I5 {...}
interface I2 {...}
interface I3 {...}
interface I4 {...}
interface I5 {...}

class ClassUtil {
    public static Set<Class<?>> getAllExtendedOrImplementedTypesRecursively(Class<?> clazz){
        ???
    }
}

import static org.junit.Assert.*;
public class ClassUtilTest {
    @Test
    public void shouldEqualClasses(){
        Set<Class<?>> types = ClassUtil.getAllExtendedOrImplementedTypesRecursively(Foo.class);
        Set<Class<?>> checklist = new HashSet<>();
        checklist.add(Foo.class);
        checklist.add(Bar.class);
        checklist.add(I1.class);
        checklist.add(I2.class);
        checklist.add(I3.class);
        checklist.add(I4.class);
        checklist.add(I5.class);
        assertTrue(checklist.containsAll(types));
        assertTrue(types.containsAll(checklist));
    }
}
Run Code Online (Sandbox Code Playgroud)

想想Arquillian ShrinkWrap创作助手.

更新:由于Class对象没有实现Comparable>我还需要找到一种创建Set(或类似类)的方法,而不需要实现Comparable接口(例如,仅依赖于类对象的hashcode).

更新: …

java class jboss-arquillian

17
推荐指数
2
解决办法
1万
查看次数

build.gradle文件,任务使用<< notation,intellij警告:"无法推断参数类型"

我是groovy和gradle的新手,并且想知道是否有人知道为什么我的scriplet不工作(编辑实际上它确实有效但警告仍然出现).这部分取自build.gradle脚本,intellij突出显示了这一点并抱怨它:"无法推断出参数类型".你能帮忙的话,我会很高兴 :)

task hellofun << {
    [silly:'billy'].each { k, v ->
        println "$k=$v"
    }
}
Run Code Online (Sandbox Code Playgroud)

编辑:我已经提交了一个错误请求,通知Intellij这个问题

编辑:显然这是一个已知的错误我将在修复错误后更新此错误

groovy intellij-idea gradle

15
推荐指数
1
解决办法
1万
查看次数

Javafx项目不能用maven编译

我有一个Java FX项目,我正在使用maven 3.0.5来构建.当我运行mvn package/install时,项目失败并抱怨包javafx.*不存在.根据我的理解,Javafx打包在Java 1.7中,因此构建不会选择它是没有意义的.当我在我的IDE(intellij)中编译它时它工作正常,之后我的maven构建也成功安装,但是我不希望每次我进行干净安装时都要通过IDE.有任何想法吗?

这是我的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/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>thenaglecode</artifactId>
        <groupId>com.thenaglecode</groupId>
        <version>1.0.0.Pre-Alpha</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>system-setup</artifactId>

    <dependencies>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-vfs2</artifactId>
            <version>2.0</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <includeEmptyDirs>true</includeEmptyDirs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>com.akathist.maven.plugins.launch4j</groupId>
                <artifactId>launch4j-maven-plugin</artifactId>
                <version>1.5.2</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>launch4j</goal>
                        </goals>
                        <configuration>
                            <headerType>gui</headerType>
                            <jre>
                                <path>C:\Program Files\Java\jre7</path>
                                <minVersion>1.7.0</minVersion>
                                <initialHeapSize>128</initialHeapSize>
                                <maxHeapSize>1024</maxHeapSize>
                            </jre>
                            <jar>${project.build.directory}/${project.build.finalName}.jar</jar> …
Run Code Online (Sandbox Code Playgroud)

java javafx maven

12
推荐指数
2
解决办法
3万
查看次数

Maven耳朵项目与ejb模块.生成application.xml时出错

在编译下面的pom时,我得到一个异常,说明core项目中缺少依赖项:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-ear-plugin:2.8:generate-application-xml (default-generate-application-xml) on project theear: Artifact[ejb:com.myapp:core] is not a dependency of the project. -> [Help 1]
Run Code Online (Sandbox Code Playgroud)

theear设置如下:

<project ...>
    ...

    <artifactId>theear</artifactId>
    <packaging>ear</packaging>

    <dependencies>
        <dependency>
            <groupId>com.myapp</groupId>
            <artifactId>web</artifactId>
            <version>${application.web.version}</version>
            <type>war</type>
            <scope>runtime</scope>
        </dependency>

        <!-- myapp projects -->
        <dependency>
            <groupId>com.myapp</groupId>
            <artifactId>core</artifactId>
        </dependency>

        ...
    </dependencies>

    <build>
        <finalName>theear</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-ear-plugin</artifactId>
                <version>2.8</version>
                <configuration>
                    <modules>
                        <webModule>
                            <groupId>com.myapp</groupId>
                            <artifactId>web</artifactId>
                            <contextRoot>/web</contextRoot>
                            <bundleFileName>web.war</bundleFileName>
                        </webModule>
                        <ejbModule>
                            <groupId>com.myapp</groupId>
                            <artifactId>core</artifactId>
                            <bundleFileName>core.jar</bundleFileName>
                        </ejbModule>
                    </modules>
                    <defaultLibBundleDir>lib/</defaultLibBundleDir>
                    <skinnyWars>true</skinnyWars>
                </configuration>
            </plugin>
            ...
        </plugins>
    </build>
</project>
Run Code Online (Sandbox Code Playgroud)

核心项目如下:

<project ...> …
Run Code Online (Sandbox Code Playgroud)

java configuration maven

10
推荐指数
1
解决办法
1万
查看次数

为具有复合ID的实体自定义HATEOAS链接生成

我已经配置了RepositoryRestResource一个PageAndSortingRepository访问包含复合ID的实体的on :

@Entity
@IdClass(CustomerId.class)
public class Customer {
    @Id BigInteger id;
    @Id int startVersion;
    ...
}

public class CustomerId {
    BigInteger id;
    int startVersion;
    ...
}

@RepositoryRestResource(collectionResourceRel = "customers", path = "customers", itemResourceRel = "customers/{id}_{startVersion}")
public interface CustomerRepository extends PagingAndSortingRepository<Customer, CustomerId> {}
Run Code Online (Sandbox Code Playgroud)

"http://<server>/api/customers/1_1"例如,当我访问服务器时,我获得了正确的资源作为json,但是_links部分中的href是错误的,并且对于我查询的任何其他客户也是如此:"http://<server>/api/customer/1"

即:

{
  "id" : 1,
  "startVersion" : 1,
  ...
  "firstname" : "BOB",
  "_links" : {
    "self" : {
      "href" : "http://localhost:9081/reps/api/reps/1" <-- This should be /1_1
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我想这是因为我的复合ID,但我对如何更改此默认行为感到兴奋.

我已经看过这个 …

spring spring-mvc spring-data-jpa spring-hateoas

9
推荐指数
2
解决办法
1万
查看次数

请参阅gradle中的单个配置的依赖关系树(使用`dependencies`任务)

每当我调用gradlew dependenciesgradle项目时,我都会得到每个配置的依赖项列表(当只配置编译时,通常包括为运行时,test和testRuntime重复多次相同的事情).

有没有办法指定特定的配置来查看依赖关系?

java groovy gradle

8
推荐指数
2
解决办法
5698
查看次数

删除lastSuccessful/lastStable jenkins时java.nio.file.DirectoryNotEmptyException

运行jenkins作业时,控制台会报告此错误:

java.nio.file.DirectoryNotEmptyException: C:\jenkins\jobs\My Job\lastSuccessful
    at sun.nio.fs.WindowsFileSystemProvider.implDelete(Unknown Source)
    at sun.nio.fs.AbstractFileSystemProvider.deleteIfExists(Unknown Source)
    at java.nio.file.Files.deleteIfExists(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at hudson.Util.createSymlinkJava7(Util.java:1194)
    at hudson.Util.createSymlink(Util.java:1112)
    at hudson.model.Run.createSymlink(Run.java:1846)
    at hudson.model.Run.updateSymlinks(Run.java:1827)
    at hudson.model.Run.execute(Run.java:1738)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:89)
    at hudson.model.Executor.run(Executor.java:240)
ln builds\lastStableBuild C:\jenkins\jobs\My Job\lastStable failed
java.nio.file.DirectoryNotEmptyException: C:\jenkins\jobs\My Job\lastStable
    at sun.nio.fs.WindowsFileSystemProvider.implDelete(Unknown Source)
    at sun.nio.fs.AbstractFileSystemProvider.deleteIfExists(Unknown Source)
    at java.nio.file.Files.deleteIfExists(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at hudson.Util.createSymlinkJava7(Util.java:1194)
    at hudson.Util.createSymlink(Util.java:1112)
    at hudson.model.Run.createSymlink(Run.java:1846)
    at hudson.model.Run.updateSymlinks(Run.java:1828)
    at hudson.model.Run.execute(Run.java:1738) …
Run Code Online (Sandbox Code Playgroud)

java jenkins

8
推荐指数
2
解决办法
9286
查看次数