小编Him*_*huR的帖子

如何访问maven multimodule项目中其他模块pom中定义的属性

在ABC的pom我已经将属性定义为abc,其中ABC是模块.现在我想在ADF模块的pom中访问该属性.

<properties>
<A.B.C>${buildNumber}</A.B.C>
</properties>

<plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>buildnumber-maven-plugin</artifactId>
            <version>1.3</version>
            <executions>
                <execution>
                <id>buildnumber</id>
                    <phase>validate</phase>
                    <goals>
                        <goal>create</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
            <timestampFormat>{0,date,dd-MM-yyyy HH:mm:ss}</timestampFormat>
            <doCheck>false</doCheck>
            <doUpdate>false</doUpdate>
            <providerImplementations>
                <svn>javasvn</svn>
            </providerImplementations>
            <revisiononscmfailure>

                    <!-- 71 Generate sequence build number based on: 72 build number and 
                        timestamp 73 -->

                    <format>Build: #{0} ({1,date})</format>

                    <items>

                        <item>buildNumber\d*</item>

                        <item>timestamp</item>

                    </items>

                </revisiononscmfailure>
        </configuration>
        <dependencies>
            <dependency>
                <groupId>com.google.code.maven-scm-provider-svnjava</groupId>
                <artifactId>maven-scm-provider-svnjava</artifactId>
                <version>2.1.1</version>
            </dependency>
            <dependency>
                <groupId>org.tmatesoft.svnkit</groupId>
                <artifactId>svnkit</artifactId>
                <version>1.8.5</version>
            </dependency>
        </dependencies>

        </plugin>
Run Code Online (Sandbox Code Playgroud)

我在$ ADF模块的pom中使用$ {ABC}作为版本的值.

<dependency>
        <groupId></groupId>
        <artifactId></artifactId>
        <version>${A.B.C}</version>
        <type>bundle</type>
    </dependency>
Run Code Online (Sandbox Code Playgroud)

所以它给了我错误:bundle必须是有效的版本,但是$ {ABC}.

编辑:

或者我可以在某种程度上使用C模块的版本,因为我已经定义:

<version>${A.B.C}</version> 
Run Code Online (Sandbox Code Playgroud)

java pom.xml maven buildnumber-maven-plugin

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

更新后插件的eclipse错误

我遇到了一个问题

This version of the rendering library is more recent than your version of ADT plug-in.
Please update ADT plug-in
Run Code Online (Sandbox Code Playgroud)

我从以下方面尝试了这一点:Eclipse报告渲染库比ADT插件更新

1. Click Help > Install New Software.
2. In the Work with field, enter: https://dl-ssl.google.com/android/eclipse/
3. Select Developer Tools / Android Development Tools.
4. Click Next and complete the wizard.
Run Code Online (Sandbox Code Playgroud)

新问题:

An error has occurred. See error log for more details.java.lang.NullPointerException
Run Code Online (Sandbox Code Playgroud)

我在Windows cmd上试过这个(再次通过一些stackoverflow论坛):

eclipse -clean -clearPersistedState
Run Code Online (Sandbox Code Playgroud)

但我没有任何解决方案

这是新消息:

An error has occurred. See error log for more details.com/android/utils/SparseArray …
Run Code Online (Sandbox Code Playgroud)

java eclipse android eclipse-plugin eclipse-adt

8
推荐指数
1
解决办法
9926
查看次数

设置textview的动态宽度

在我的项目中,我需要根据收到的数据动态绘制textview行以显示它.为了正确对齐它们,我使用了Table Row n xml,并在java代码中调用它.现在,在他们的LayoutParam中,我已经给出了MATCH_PARENT,但它根据接收的数据长度包装文本.现在,我想修复表格视图的字段宽度.我在postExecute方法中执行所有这些过程.在这个方法中,我使用setWidth函数根据标题行元素的宽度来设置它.这里,Sno是一个视图,而size是包含headerRow所有元素宽度的数组.

 Sno.setTag(patient);
 Sno.setWidth(size[0]); 
Run Code Online (Sandbox Code Playgroud)

但它没有解决这个问题,当我尝试getWidth看到它的宽度,它显示其值0.然后我尝试使用LinearLayout.LinearParams设置此宽度

LinearLayout.LayoutParams params_sno = new LinearLayout.LayoutParams(size[0],
LinearLayout.LayoutParams.MATCH_PARENT);
Sno.setLayoutParams(params_sno);
Run Code Online (Sandbox Code Playgroud)

但是仍然没有任何好处,其次,如果我从LayoutParams的宽度移除MATCH_PARENT,它的宽度从标题行元素的宽度增加.没有数据的字段是不可见的.

java android

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

列出<interfaceI> vs List <?在java中扩展InterfaceI>

Arraylist with List<interfaceI>List<? extends InterfaceI>both都有实现interfaceI的类对象.那什么时候应该用?

java generics collections arraylist

6
推荐指数
1
解决办法
113
查看次数

O(n) 是否大于 O(2^log n)

我在数据结构书籍复杂性层次图中读到 n 大于 2 log n。但无法理解如何以及为什么。在使用 2 的幂作为 n 的简单示例时,我得到等于 n 的值。

书中没有提到,但我假设它以 2 为基数(因为上下文是 DS 复杂性)

a) 是O(n) > O(pow(2,logn))

b)O(pow(2,log n))优于O(n)

math optimization complexity-theory time-complexity asymptotic-complexity

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

扁平的pom没被使用?

这是一个多模块的maven项目.我在父母pom中加入了flatten-maven-plugin

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>flatten-maven-plugin</artifactId>
    <version>1.0.0-beta-2</version>
    <configuration>
    </configuration>
Run Code Online (Sandbox Code Playgroud)

在父pom中定义了一个属性scl_version,并在子pom中使用了$ {scl_version}.值为0.0.1.

当我跑mvn flatten:flatten

它会生成一个警告:[警告]'版本'包含一个表达式,但应该是一个常量.

在所有模块中创建扁平的pom,包括父级和所有子级.

扁平的pom具有子pom的版本标签中的属性值.但是,当我给出,mvn安装它仍然会发出警告,版本应该是常量,但它是一个表达式.

http://mojo.codehaus.org/flatten-maven-plugin/plugin-info.html

但是文件说:

此MOJO实现了生成展平POM并可能更新POM文件的目标展平,以便当前MavenProject的文件指向展平的POM而不是原始的pom.xml文件.扁平POM是原始POM的简化版本,其重点仅包含消耗它的重要信息.因此,剥离了开发人员维护和构建项目工件所需的信息.

所以当我做mvn安装时,它不应该生成警告.

mvn install和mvn flatten:flatten both生成此警告:

[警告]'版本'包含表达式但应该是常量.

我错过了什么,是不是使用flattened-pom.xml.我需要指定一些东西吗?

父母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">
<modelVersion>4.0.0</modelVersion>
<groupId>org.a.b</groupId>
<artifactId>ABC</artifactId>
<version>0.0.1</version>
<packaging>pom</packaging>
<name>ABC</name>
<modules>
    <module>Resources</module>
    <module>ResourceTree</module>
    <module>Service</module>
    <module>Transport</module>
<module>Branding</module>
Run Code Online (Sandbox Code Playgroud)

属性标签从这里开始

<scl_version>0.0.1</scl_version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven-compiler-plugin.version>3.1</maven-compiler-plugin.version>
<karaf.deploy.build.folder>${env.KARAF_BASE}/deploy</karaf.deploy.build.folder>
Run Code Online (Sandbox Code Playgroud)

属性标签在这里结束

<profiles>
    <profile>
        <id>code_coverage</id>
        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${maven-compiler-plugin.version}</version>
                    <configuration>
                        <source>1.7</source>
                        <target>1.7</target>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>0.7.0.201403182114</version>
                    <executions>
                        <execution>
                            <id>default-instrument</id>
                            <goals>
                                <goal>instrument</goal>
                            </goals>
                        </execution> …
Run Code Online (Sandbox Code Playgroud)

java maven-2 pom.xml maven-3

4
推荐指数
1
解决办法
3225
查看次数

哪个更好?

我需要维护一个包含两个字符串类型值的列表,例如v1,v2,每个键说k.什么是更好的选择

  1. Hashmap,其值包含包含v1和v2的字符串,并使用split()在选择后检索正确的值.
  2. Hashmap,其值包含两个字符串变量的数组

我正在创建一个Android应用程序,所以只关注性能.在第二种情况下,我可以直接访问,但每个值将包含另一个数组(我不知道,但它看起来像一个复杂的方式),而在第一种情况下,它将在每个访问上使用拆分函数,如v.split(",")[0 ]

请指导我.

Map<String,String[]> listMap= new HashMap<String, String[]>();
Map<String,String> listMap1= new HashMap<String, String>();;

for (int i = 1; i < tl.getChildCount(); i++) {
    TableRow row = (TableRow) tl.getChildAt(i);
    COLOR_TABLE clr = (COLOR_TABLE) row.getTag();

    if (clr == COLOR_TABLE.green) {
        //comp
        String x1=listMap1.get( ((TextView) row.getChildAt(0)).getText());
        String x2=listMap.get( ((TextView) row.getChildAt(0)).getText());
        // now i have to add two string values in a list seperately
    }
}
Run Code Online (Sandbox Code Playgroud)

java performance android

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

字符串拆分功能无法正常工作

我试图用毫秒分割日期并以我的格式打印,但索引超出绑定异常.它在split("/")的情况下工作,但不在split(".")的情况下工作.

我不知道为什么会这样.

代码是:

public class c {

public static void main(String[] arg)
{
    Date date=new Date();                                                                    
     DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss.FFF");                   
     System.out.println(formatter.format(date));

     String a=formatter.format(date);
     String b[]=a.split(" ")[0].split("/");
     String x1=(Integer.parseInt(b[2])-2000)+b[1]+b[0];
     System.out.println("date part is : "+x1);
     String c[]=a.split(" ")[1].split(":");
     System.out.println(c[0]);
     System.out.println(c[1]);
     System.out.println(c[2]);
     System.out.println(c[2].trim().split(".")[0]);// exception at this line
     System.out.println(c[2].trim().split(".")[1]);
     String x2=c[0]+c[1]+c[2].split(".")[0]+c[2].split(".")[1]+"";
     System.out.println("time part is : "+x2);
}
}
Run Code Online (Sandbox Code Playgroud)

日志是:

08/10/2013 12:02:18.002
date part is : 131008
12
02
18.002
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException:0   at c.main(c.java:22)
Run Code Online (Sandbox Code Playgroud)

java

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