2015-12-29 25 views
5

Chcę wyświetlić sygnaturę czasową kompilacji na mojej stronie internetowej, używając Wildfly 9.. Stworzyłem buildInfo.properties z build.timestamp=${timestamp}.Jak utworzyć znacznik czasu kompilacji w aplikacji internetowej Java za pomocą Mavena?

pom.xml:

<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>com.daksa.consolidated.statement</groupId> 
     <artifactId>consolidated-statement</artifactId> 
     <version>1.0-SNAPSHOT</version> 
    </parent> 
    <artifactId>consolidated-statement-war</artifactId> 
    <packaging>war</packaging> 
    <name>consolidated-statement-war</name> 
    <description>consolidated-statement-war</description> 


<properties> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    <maven.compiler.target>1.7</maven.compiler.target> 
    <maven.compiler.source>1.7</maven.compiler.source> 
    <timestamp>${maven.build.timestamp}</timestamp> 
</properties> 

<dependencies> 
    <!-- Daksa --> 
    <dependency> 
     <groupId>com.daksa.sandra</groupId> 
     <artifactId>sandra-api</artifactId> 
     <version>2.0-SNAPSHOT</version> 
    </dependency> 

    <!-- Java EE --> 
    <dependency> 
     <groupId>javax</groupId> 
     <artifactId>javaee-api</artifactId> 
     <version>7.0</version> 
     <scope>provided</scope> 
    </dependency> 

    <!-- Logging --> 
    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>slf4j-api</artifactId> 
     <version>1.7.12</version> 
    </dependency> 
    <dependency> 
     <groupId>ch.qos.logback</groupId> 
     <artifactId>logback-classic</artifactId> 
     <version>1.1.1</version> 
    </dependency> 
    <dependency> 
     <groupId>ch.qos.logback</groupId> 
     <artifactId>logback-core</artifactId> 
     <version>1.1.1</version> 
    </dependency> 

    <!-- Testing --> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>4.12</version> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.mockito</groupId> 
     <artifactId>mockito-all</artifactId> 
     <version>1.9.5</version> 
     <scope>test</scope> 
    </dependency> 

    <!-- Primefaces --> 
    <dependency> 
     <groupId>org.primefaces</groupId> 
     <artifactId>primefaces</artifactId> 
     <version>5.3</version> 
    </dependency> 
    <dependency> 
     <groupId>org.primefaces.extensions</groupId> 
     <artifactId>primefaces-extensions</artifactId> 
     <version>3.0.0</version> 
    </dependency> 

    <!-- Shiro --> 
    <dependency> 
     <groupId>org.apache.shiro</groupId> 
     <artifactId>shiro-core</artifactId> 
     <version>1.2.3</version> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.shiro</groupId> 
     <artifactId>shiro-web</artifactId> 
     <version>1.2.3</version> 
    </dependency> 

    <!-- POI --> 
    <dependency> 
     <groupId>org.apache.poi</groupId> 
     <artifactId>poi</artifactId> 
     <version>3.13</version> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.poi</groupId> 
     <artifactId>poi-ooxml</artifactId> 
     <version>3.13</version> 
    </dependency> 

    <!-- CSV --> 
    <dependency> 
     <groupId>org.apache.commons</groupId> 
     <artifactId>commons-csv</artifactId> 
     <version>1.2</version> 
    </dependency> 

    <!-- JSON --> 
    <dependency> 
     <groupId>com.fasterxml.jackson.core</groupId> 
     <artifactId>jackson-core</artifactId> 
     <version>2.6.3</version> 
    </dependency> 
    <dependency> 
     <groupId>com.fasterxml.jackson.core</groupId> 
     <artifactId>jackson-databind</artifactId> 
     <version>2.6.3</version> 
    </dependency> 
    <dependency> 
     <groupId>com.fasterxml.jackson.core</groupId> 
     <artifactId>jackson-annotations</artifactId> 
     <version>2.6.3</version> 
    </dependency> 
    <dependency> 
     <groupId>com.fasterxml.jackson.module</groupId> 
     <artifactId>jackson-module-jaxb-annotations</artifactId> 
     <version>2.6.3</version> 
    </dependency> 

    <!-- Guava --> 
    <dependency> 
     <groupId>com.google.guava</groupId> 
     <artifactId>guava</artifactId> 
     <version>18.0</version> 
    </dependency> 

    <!-- Atmosphere --> 
    <dependency> 
     <groupId>org.atmosphere</groupId> 
     <artifactId>atmosphere-runtime</artifactId> 
     <version>2.4.1</version> 
    </dependency> 

    <!-- Apache Commons Code --> 
    <dependency> 
     <groupId>commons-codec</groupId> 
     <artifactId>commons-codec</artifactId> 
     <version>1.10</version> 
    </dependency> 

    <!-- Ehcache --> 
    <dependency> 
     <groupId>net.sf.ehcache</groupId> 
     <artifactId>ehcache</artifactId> 
     <version>2.10.1</version> 
    </dependency> 

      <!-- Jasper Report --> 
      <dependency> 
        <groupId>net.sf.jasperreports</groupId> 
        <artifactId>jasperreports</artifactId> 
        <version>6.2.0</version> 
        <type>jar</type> 
        <exclusions> 
         <exclusion> 
          <artifactId>javassist</artifactId> 
          <groupId>jboss</groupId> 
         </exclusion> 
        </exclusions> 
      </dependency> 
      <dependency> 
        <groupId>org.codehaus.groovy</groupId> 
        <artifactId>groovy-all</artifactId> 
        <version>2.4.5</version> 
        <exclusions> 
         <exclusion> 
          <artifactId>javassist</artifactId> 
          <groupId>jboss</groupId> 
         </exclusion> 
        </exclusions> 
      </dependency> 

    <!-- Common --> 
    <dependency> 
     <groupId>commons-net</groupId> 
     <artifactId>commons-net</artifactId> 
     <version>3.4</version> 
     <type>jar</type> 
    </dependency>            
</dependencies> 

<profiles> 
    <profile> 
     <id>default</id> 
     <activation> 
      <activeByDefault>true</activeByDefault> 
     </activation> 
     <build> 
      <plugins> 
       <plugin> 
        <artifactId>maven-surefire-plugin</artifactId> 
        <version>2.16</version> 
        <configuration> 
               <skip>true</skip> 
        </configuration> 
       </plugin> 
      </plugins> 
     </build> 
    </profile> 
</profiles> 
    <build> 
     <resources> 
      <resource> 
       <directory>src/main/resources</directory> 
       <filtering>true</filtering> 
      </resource> 
     </resources>    
    </build> 
<repositories> 

</repositories> 

Kiedy uruchamiam program, wystąpił błąd:

"{\"WFLYCTL0080: Failed services\" => {\"jboss.persistenceunit.\\"consolidated-statement-war-1.0-SNAPSHOT.war#consolidatedStatement\\".FIRST_PHASE\" => \"org.jboss.msc.service.StartException in service jboss.persistenceunit.\\"consolidated-statement-war-1.0-SNAPSHOT.war#consolidatedStatement\\".FIRST_PHASE: org.hibernate.jpa.boot.archive.spi.ArchiveException: Could not build ClassFile Caused by: org.hibernate.jpa.boot.archive.spi.ArchiveException: Could not build ClassFile\"}}"

Ale jeśli usunąć sekcję kompilacji w moim pom. xml, aplikacja działa, ale znacznik czasu nie jest wyświetlany. Jak uzyskać znacznik czasu do wyświetlenia?

Odpowiedz

4

Wygląda na to, że problem występuje po zastosowaniu filtrowania w całym folderze src/main/resources.

starać się ograniczyć tylko do filtrowania buildInfo.properties jak opisano w http://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html

<build> 
... 
<resources> 
    <resource> 
    <directory>src/main/resources</directory> 
    <filtering>true</filtering> 
    <includes> 
     <include>**/buildInfo.properties</include> 
    </includes> 
    </resource> 
    <resource> 
    <directory>src/main/resources</directory> 
    <filtering>false</filtering> 
    <excludes> 
     <exclude>**/buildInfo.properties</exclude> 
    </excludes> 
    </resource> 
    ... 
</resources> 
... 

+0

Hi, próbowałem swoje rozwiązanie i działa ... Dziękuję bardzo – berry