2015-01-02 14 views
22

Tôi đã thêm mã plugin mvn jetty vào dự án pom.xml của mình.Không tìm thấy plugin nào cho tiền tố 'cầu cảng' trong dự án hiện tại

<plugin> 
    <groupId>org.mortbay.jetty</groupId> 
    <artifactId>maven-jetty-plugin</artifactId> 
    <version>6.1.26</version> 
    <configuration> 
    <contextPath>/redkites</contextPath> 
    </configuration> 
    <executions> 
    <execution> 
     <id>start-jetty</id> 
     <phase>deploy</phase> 
     <goals> 
     <goal>run</goal> 
     </goals> 
     <configuration> 
     <scanIntervalSeconds>10</scanIntervalSeconds> 
     <daemon>true</daemon> 
     </configuration> 
    </execution> 
    </executions> 
</plugin> 

Khi tôi sử dụng lệnh sudo mvn compilesudo mvn clean install, tôi không tìm thấy bất kỳ lỗi & xây dựng thành công, nhưng khi tôi gõ lệnh sudo mvn jetty:run, tôi nhận được một lỗi:

[ERROR] No plugin found for prefix 'jetty' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/root/.m2/repository), central (http://repo.maven.apache.org/maven2)] -> [Help 1] 
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 
[ERROR] Re-run Maven using the -X switch to enable full debug logging. 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles: 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundForPrefixException 

Xin gợi ý một cách để giải quyết nó. Cảm ơn bạn

+0

Thử chạy tất cả lệnh 'mvn' mà không cần sudo. –

+0

Bản sao có thể có của [Thiếu Maven Plugin Jetty] (http://stackoverflow.com/questions/10426557/missing-maven-plugin-jetty) – cellepo

Trả lời

31

Bạn có thể cần thêm org.mortbay.jetty vào danh sách các groupId s nhìn lên theo mặc định.

Vì vậy, chỉnh sửa của bạn ${user.home}/.m2/settings.xml phù hợp:

<pluginGroups> 
    <!-- your existing plugin groups if any --> 
    ... 
    <pluginGroup>org.mortbay.jetty</pluginGroup> 
</pluginGroups> 

Trích dẫn phần Shortening the Command Line của plugin development guide,

... add your plugin's groupId to the list of groupIds searched by default. To do this, you need to add the following to your ${user.home}/.m2/settings.xml file:

<pluginGroups> 
    <pluginGroup>sample.plugin</pluginGroup> 
</pluginGroups> 

Look here để biết thêm về những gì groupId s đang nhìn lên mặc định:

By default, Maven will search the groupId org.apache.maven.plugins for prefix-to-artifactId mappings for the plugins it needs to perform a given build.

...

Maven will always search the following groupId's after searching any plugin groups specified in the user's settings:

  • org.apache.maven.plugins
  • org.codehaus.mojo
23

nếu bạn không tìm thấy file settings.xml trong thư mục chính của bạn

sau đó thêm các tập tin mặc định settings.xml

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 
         http://maven.apache.org/xsd/settings-1.0.0.xsd"> 
    <localRepository>${user.home}/.m2/repository</localRepository> 
    <interactiveMode>true</interactiveMode> 
    <usePluginRegistry>false</usePluginRegistry> 
    <offline>false</offline> 
    <pluginGroups> 
    <pluginGroup>org.mortbay.jetty</pluginGroup> 
    </pluginGroups> 
</settings> 
0

Đó là những gì làm việc cho tôi trong một dự án Maven multimodule trong Eclipse :

1 Mở hộp thoại Cấu hình chạy.

2.Look tại “cơ sở Thư mục:” Có thực sự là thư mục của submodule webapp của bạn hoặc là nó module mẹ ‘s thư mục?

3 Nếu sau này, hãy nhấp vào nút "Không gian làm việc" và chọn thư mục của nhóm (webapp).

1

Tôi đã chạy lệnh trong thư mục trong đó dự án đã có mặt nhưng lệnh hoạt động tốt sau khi chuyển sang một thư mục, tức là trong một thư mục có tất cả các tệp của dự án.

Các vấn đề liên quan