WebApp资源进入目标



Web资源没有被复制到目标/类文件夹,因此不在目标/$ {finalName}/web-inf/class Class Folder中。

目前mvn clean install的输出:

target/classes/(src/main/java)

但是我也在尝试得到:

target/classes/(src/main/webapp)

pom:

<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>StrategicTestArchitecture</groupId>
  <artifactId>STATestAPI</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.5.1</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>3.0.0</version>
  <!--        <configuration>
            <warSourceDirectory>src/main/webapp</warSourceDirectory>
          <warSourceDirectory>WebContent</warSourceDirectory>
          <webResouces>
            <resource>
                <directory>src/main/webapp</directory>
                <targetPath>WEB-INF/classes</targetPath>
            </resource>
            <resource>
                <directory>${baseDir}/src/main/webapp</directory>
                <targetPath>target/${finalName}/WEB-INF</targetPath>
            </resource>
          </webResouces>
        </configuration> -->
      </plugin>
    </plugins>
    <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>Spring.properties</include>
                </includes>
            </resource>
    </resources>
  </build>
  <profiles>
        <profile>
            <id>staging</id>
            <activation>
                <property>
                    <name>environment</name>
                    <value>staging</value>
                </property>
            </activation>
            <properties>
                <hibernate.dialect>org.hibernate.dialect.Oracle10gDialect</hibernate.dialect>
                <hibernate.show_sql>true</hibernate.show_sql>
                <hibernate.url>myoracleurl</hibernate.url>
                <DriverClassName>oracle.jdbc.driver.OracleDriver</DriverClassName>
            </properties>
        </profile>
        <profile>
            <id>alpha</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <hibernate.dialect>org.hibernate.dialect.Oracle10gDialect</hibernate.dialect>
                <hibernate.show_sql>true</hibernate.show_sql>
                <hibernate.url>myoracleurl</hibernate.url>
                <DriverClassName>oracle.jdbc.driver.OracleDriver</DriverClassName>
            </properties>
        </profile>
    </profiles>
  <properties>
        <!-- Generic properties -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.8</java.version>
        <!-- SPRING & HIBERNATE / JPA -->
        <spring.version>4.3.5.RELEASE</spring.version>
        <hibernate.version>5.2.5.Final</hibernate.version>
  </properties>
  <dependencies>
    <dependency>
        <groupId>StrategicTestArchitecture</groupId>
        <artifactId>Commons</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>
  </dependencies>
</project>

任何人都可以阐明为什么这些文件未被复制到输出目录中?

如史蒂夫·C(Steve C(所述,Web资源无需在类路径上,因此可以将Web配置留为空白。这将将所有内容从src/main/webapp目录复制到战争文件的根部。

在我的情况下,我们有一个名为资源的文件夹位于src/main/webapp/resources,其中包含我们的HTML/CSS/JS

用于在春季配置中参考注册表可以进行修改:

public void addResourceHandlers(ResourceHandlerRegistry registry){
    registry.addResourceHandler("/resources/**").addResourceLocations("resources/");
}

相关内容

  • 没有找到相关文章

最新更新