我的应用程序启动后,我只能在webjars目录中的客户端看到几个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"/>
答案 0 :(得分:1)
我想我发现了自己的错误。
我必须使用<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上传成功。