- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我没有找到我正在处理的特定场景的答案。我有一个 Maven Web 项目,我想在 Tomcat 服务器上运行(目前运行良好)。我的问题是,我需要使用 jQuery 和 Bootstrap,但它不起作用,官方资源也没有提供在没有任何额外框架的情况下使用它的方法。
这就是我到目前为止所做的:
我的 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.ls5.wt2</groupId>
<artifactId>micro</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>micro Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>webjars-locator</artifactId>
<version>0.1</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>webjars-locator</artifactId>
<version>0.32-1</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>3.3.7</version>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.0.Final</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
</dependency>
</dependencies>
<build>
<finalName>micro</finalName>
</build>
</project>
target/appName/WEB-INF/lib 文件夹包含 jQuery、Bootstrap 和所有其他依赖库的 jar 文件
<html>
<head>
<script src="/webjars/jquery/3.1.1/jquery.min.js"></script>
<script src="/webjars/bootstrap/3.3.7-1/js/bootstrap.min.js"></script>
<title>WebJars Demo</title>
<link rel="stylesheet"
href="/webjars/bootstrap/3.3.7-1/css/bootstrap.min.css" />
</head>
<body>
<div class="container"><br/>
<div class="alert alert-success">
<a href="#" class="close" data-dismiss="alert"
aria-label="close">×</a>
<strong>Success!</strong> It is working as we expected.
</div>
</div>
</body>
</html>
index.html
在我的 target/appName/
文件夹中,我知道在 "target/appName/webjars/jquery/3.1. index.html
引用的1/jquery.min.js"
不存在,我需要知道什么?我以为 maven 会那样做。最佳答案
首先,您有重复的 webjars-locator 依赖 - 修复它。
现在,关于你的问题:通过删除前面的“/”来修复您的 js 和 css 导入: 更改 <script src="/webjars/.../>
至 <script src="webjars/.../>
检查 full example , 如果你想要
希望这会奏效。
关于java - 如何在没有任何框架的情况下使用 Maven 的 webjars,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44256047/
我是 WebJars 的新手,到目前为止,与仅使用 Bower 相比,它们没有看到任何真正的优势。什么证明将前端 JS 放入后端 JAR 的想法是合理的? 请至少说出一个或多个“目标”使用WebJar
我有一个 spring boot(我使用 Thymeleaf 进行模板化)项目,我想在其中使用一些 jQuery 库。 不幸的是,webjars 根本没有加载。我尝试了很多配置,但都失败了。 这是我的
关于 SO 的许多问题都涉及位于 Spring-Boot webjars 中的各种资源的无效路径。目前我有系绳问题但是我不想再专门介绍 tether 的 webjar 文件/路径,所以想问: 是否有任
我有一个运行嵌入式 jetty 服务器的项目。另外,我在项目的依赖项中有 angularjs-1.2.12.jar 。 如何配置 jetty,以公开 META-INF/资源中的文件。我尝试执行以下操作
我的 pom 中有依赖项: org.webjars extjs 6.0.0 将我的项目构建成 war 后,我收到了一个超过 200MB 的包。是否有可能排除包 /webja
我正在尝试将 graceful-fs webjar 包含在我的网络应用程序中。我在 pom.xml 文件中包含了以下内容: org.webjars.npm graceful-fs
我正在将一个 Play 项目迁移到 2.3,并使用 ShaggyYeti 的 sbt-sass plugin 编译我的 SCSS 文件(来自 play-sass plugin 的变化)。我将所有内容打
我有一个 Spring Boot 服务器,其中包含一个带有我的客户端代码的 webjar。我想在我的服务的根目录中提供此 webjar,而不是在/webjar/name/version 位置。 我能够
我正在尝试根据他们的 documentation 使用 webjars 进行引导。 org.webjars bootstrap 3.1.0
我正在使用 Spring Boot、thymeleaf 和 webjars 创建一个非常基本的小型 Web 应用程序。 我想要什么:使用 webjars 包含 jquery 和 bootstrap 我
我试图在我的 Spring Boot 项目中包含 Bootstrap 4,但我看到错误:Bootstrap tooltips require Popper.js 所以我包含了依赖项: org.w
我正在使用 spring mvc 和 spring boot 开发一个网络应用程序,我有一个关于 webjars 的问题。要在 thymeleaf 中添加 webjar 的路径,我们执行以下操作:th
我刚刚找到 Maven WebJars,但我想知道如何在完成我的项目后缩小这些文件。我想使用类似 maven 插件的东西,但我还没有找到任何人。如果有人告诉我一个会很有帮助。谢谢 最佳答案 有一个项目
我有一个启用了 Spring Security 的 Spring Boot 应用程序,配置如下: @Override protected void configure(HttpSecu
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 5 年前。
我在我的应用程序中使用 Spark Framework,并使用 staticFileLocation("/META-INF/resources/"); 这样我就可以使用 webjar,其中包含 css
我没有找到我正在处理的特定场景的答案。我有一个 Maven Web 项目,我想在 Tomcat 服务器上运行(目前运行良好)。我的问题是,我需要使用 jQuery 和 Bootstrap,但它不起作用
我有一个 Spring Boot 应用程序,它充当我前端的服务器,由 webpack 构建并包含在我的 spring boot web 存档中。 我使用 webjars 访问我的前端脚本和内容。 但是
我想制作一个基于Spring MVC、Semantic-UI框架和Gradle构建工具的网页。问题是,当我尝试从 WebJars 导入语义文件时,JSP 页面无法访问它们。当我使用从 cdnjs 导入
为了在我的 Play 应用程序中使用 WebJars,我添加了以下路线 GET /webjars/*file controllers.WebJarAssets.at(
我是一名优秀的程序员,十分优秀!