我跑
mvn jetty:run
命令我正在
- 找不到前缀'码头'在当前项目和插件组[org.apache.maven.plugins,org.codehaus.mojo]中可用 存储库[local(C:\ work.m2 \ repository),错误 -
控制器
package com.himtech.googlechart;
//imports are here
@Controller
@RequestMapping("/gcharts")
public class GglPieChart
{
@RequestMapping(value = "/piechart", method = RequestMethod.GET)
public String drawPieChart(ModelMap model)
{
Slice s1 = Slice.newSlice(15, Color.newColor("CACACA"), "Mac", "Mac");
Slice s2 = Slice.newSlice(50, Color.newColor("DF7417"), "Window","Window");
Slice s3 = Slice.newSlice(25, Color.newColor("951800"), "Linux","Linux");
Slice s4 = Slice.newSlice(10, Color.newColor("01A1DB"), "Others","Others");
PieChart pieChart = GCharts.newPieChart(s1, s2, s3, s4);
pieChart.setTitle("Google Pie Chart", Color.BLACK, 15);
pieChart.setSize(720, 360);
pieChart.setThreeD(true);
model.addAttribute("pieUrl", pieChart.toURLString());
return "display";
}
}
的web.xml
<web-app id="WebApp_ID" version="2.5"
xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd">
<display-name>SpringMVC 3.2 + Google Chart</display-name>
<servlet>
<servlet-name>frontController</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/applnConfig.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>frontController</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
applnConfig.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">
<context:component-scan base-package="com.himtech" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/jsps/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
</beans>
的pom.xml
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>himtech</groupId>
<artifactId>springmvc_googlechart</artifactId>
<packaging>war</packaging>
<version>1.0.0</version>
<name>springmvc_googlechart Maven Webapp</name>
<properties>
<spring.version>3.2.1.RELEASE</spring.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>com.googlecode.charts4j</groupId>
<artifactId>charts4j</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>springmvc_googlechart</finalName>
</build>
</project>
答案 0 :(得分:2)
您收到此错误是因为jetty
插件前缀为not recognized by default(作为默认插件的一部分),也未在您的设置中配置。
更改您提到的build
部分,如下所示(即将Jenkins Maven插件添加到其中):
<build>
<finalName>springmvc_googlechart</finalName>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.2.8.v20150217</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<httpConnector>
<port>7777</port>
</httpConnector>
</configuration>
</plugin>
</plugins>
</build>
通过将Jetty Maven插件定义为POM的一部分,Maven将从命令行正确识别jetty
前缀/别名,因此执行以下操作将起作用:
mvn jetty:run
注意:在上面的配置中,Jetty将在端口7777
上运行(因此可以从http://localhost:7777
访问),您可以根据需要进行更改。默认情况下,应用程序将部署在服务器根目录下(前面提到的URL)。如果您想从http://localhost:7777/springmvc_googlechart
访问它,则可以将以下内容添加到上面的configuration
部分:
<webApp>
<contextPath>/${project.build.finalName}</contextPath>
</webApp>
检查official plugin documentation以进一步配置。