java - 客户端的webjars目录几乎是空的

标签 java jquery maven spring-boot webjars

我的应用程序启动后,我只能在客户端的 webjars 目录中看到几个 js 文件:

  • webjars/jquery/3.1.1/jquery.js
  • webjars/jquery/3.1.1/jquery.min.js

但是我没有看到任何其他必要的js文件

这是我的配置和代码:

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>com.gmail.user</groupId>
    <artifactId>solo</artifactId>
    <version>1.0-SNAPSHOT</version>

    <packaging>war</packaging>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.1.RELEASE</version>
        <relativePath/>
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.8</java.version>
        <jstl.version>1.2</jstl.version>
        <gson.version>2.7</gson.version>
        <bootstrap.version>3.3.7</bootstrap.version>
        <jquery.version>3.1.1</jquery.version>
        <jquery-ui.version>1.12.1</jquery-ui.version>
        <jquery-datatables.version>1.10.12</jquery-datatables.version>
        <jquery-dateFormat.version>1.0.2</jquery-dateFormat.version>
        <momentjs.version>2.15.0</momentjs.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-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>webjars-locator</artifactId>
            <version>0.32</version>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>bootstrap</artifactId>
            <version>${bootstrap.version}</version>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>jquery</artifactId>
            <version>${jquery.version}</version>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>jquery-ui</artifactId>
            <version>${jquery-ui.version}</version>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>datatables</artifactId>
            <version>${jquery-datatables.version}</version>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>jquery-dateFormat</artifactId>
            <version>${jquery-dateFormat.version}</version>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>momentjs</artifactId>
            <version>${momentjs.version}</version>
        </dependency>

        <dependency>
            <groupId>net.sourceforge.nekohtml</groupId>
            <artifactId>nekohtml</artifactId>
            <version>1.9.22</version>
        </dependency>

        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>${gson.version}</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

Application.java

package com.gmail.user;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Application{

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

application.properties

spring.datasource.url=jdbc:mysql://localhost/solo
spring.datasource.username=root
spring.datasource.password=1
spring.datasource.driver-class-name=com.mysql.jdbc.Driver

logging.level.org.hibernate.SQL=debug
logging.level.org.springframework.web:INFO

spring.thymeleaf.mode=LEGACYHTML5
spring.thymeleaf.cache=false

_parent.html

    <script type="text/javascript" src="/webjars/jquery/3.1.1/jquery.min.js"/>
    <script src="/webjars/jquery-ui/1.12.1/jquery-ui.min.js"/>
    <link rel="stylesheet" type="text/css" href="/webjars/jquery-ui/1.12.1/jquery-ui.min.css"/>
    <script type="text/javascript" charset="utf8" src="/webjars/datatables/1.10.12/js/jquery.dataTables.js"/>
    <link rel="stylesheet" type="text/css" href="/webjars/datatables/1.10.12/css/jquery.dataTables.css"/>
    <script src="/webjars/jquery-dateFormat/1.0.2/jquery-dateFormat.js"/>

    <link rel="stylesheet" href="/webjars/bootstrap/3.3.7/css/bootstrap.min.css"/>
    <link rel="stylesheet" href="/webjars/bootstrap/3.3.7/css/bootstrap-theme.min.css"/>>
    <script src="/webjars/bootstrap/3.3.7/js/bootstrap.min.js"/>

    <script src="/webjars/momentjs/2.15.0/moment.js"/>

最佳答案

我想我发现了我的错误。 我不得不关闭<script>标签为 </script>但不包括 />

这是错误的:

<script type="text/javascript" src="/webjars/jquery/3.1.1/jquery.min.js"/>

这是正确的:

<script type="text/javascript" src="/webjars/jquery/3.1.1/jquery.min.js"></script>

但我还是不明白为什么文件 jquery.js 和 jquery.min.js 上传成功。

关于java - 客户端的webjars目录几乎是空的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39768954/

相关文章:

java - 是否可以将特定类型的不可变集绑定(bind)到 Guice 中的实例?

Java:重新连接断开的网络共享

jquery - Activex 控件上的模态对话框

javascript - 如何在html中使用jquery打印表单值

maven - CompilerMojo#execute() 导致链接错误 (java.lang.NoSuchMethodError) 并且可能已过时

java - ADFm 以外的任何 JSR 227 实现?

java - Android 跟踪 Azure CloudBlockBlob 上传进度

javascript - 如何使用 Clean jQuery 日期和时间选择器插件 - datetimepicker 设置从一个选择器到另一个选择器的日期

java - native 镜像的 Spring Boot 构建镜像失败

ios - Xcode-Maven-Plugin 是否可以在 PC 上构建 iOS 应用程序