我正在尝试在我的maven webapp中集成bower这里是我的pom.xml和bower.json,但我无法下载依赖项。这是我的pom.xml和bower.json文件。还有一个问题我需要nodejs或npm help来下载依赖项吗?
bower.json:
{
"name": "Bower1",
"version": "1.0.0",
"description": "javaee7-angular JavaScript dependencies.",
"private": true,
"dependencies": {
"angular": "1.2.0",
"jquery": "1.9.1",
"angular-bootstrap": "0.10.0",
"angular-grid": "2.0.7"
}
}
的pom.xml:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>Bower1</finalName>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>bower</executable>
<arguments>
<argument>install</argument>
</arguments>
<workingDirectory>${basedir}/src/main/webapp</workingDirectory>
</configuration>
</plugin>
</plugins>
</build>
答案 0 :(得分:3)
1.在本地系统中安装npm
2.在您的专家pom.xml
<build></build>
代码中添加以下插件
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>0.0.20</version>
<executions>
<execution>
<id>bower install</id>
<goals>
<goal>bower</goal>
</goals>
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
3.在bower.json
根文件夹
webapp
文件
{
"name": "BowerTest",
"version": "1.0.0",
"private": true,
"dependencies": {
"angular": "1.2.0",
"jquery": "1.9.1",
"bootstrap":"3.3.7",
"css":""
}}
4。如果您要添加任何依赖项,请在dependencies
中添加您的依赖项,如上面bower.json
文件所示。
bower install
,在此安装后,将在根路径中创建一个文件夹,如bower_components
,您可以在其中找到您的依赖项,然后将这些依赖项引用到您的视图层。 / LI>
醇>
答案 1 :(得分:0)