我是jenkins的新手,它将应用程序部署在localhost tomcat上,但出现错误未经授权。
[错误]无法在项目Transpoort上执行目标org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy(默认部署):无法检索远程元数据com.ailogics:transpoort:0.0 .1-SNAPSHOT / maven-metadata.xml:无法从/传输元数据com.ailogics:transpoort:0.0.1-SNAPSHOT / maven-metadata.xml(http://localhost:8080/manager/text/deploy?path=/transport):未经授权,原因短语:。 -> [帮助1] [错误] [错误]要查看错误的完整堆栈跟踪,请使用-e开关重新运行Maven。 [错误]使用-X开关重新运行Maven以启用完整的调试日志记录。 [错误] [ERROR]有关错误和可能的解决方案的详细信息,请阅读以下文章: [错误] [帮助1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
这是我的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.ailogics</groupId>
<artifactId>transpoort</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>transport</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<profiles>
<profile>
<id>tomcat-localhost</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<tomcat-server>localhost</tomcat-server>
<tomcat-url>http://localhost:8080/manager</tomcat-url>
</properties>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>2.3.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<!--<scope>provided</scope>-->
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.cloudinary</groupId>
<artifactId>cloudinary-http44</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>org.mindrot</groupId>
<artifactId>jbcrypt</artifactId>
<version>0.3m</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<!-- enable deploying to tomcat -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<server>${tomcat-server}</server>
<url>${tomcat-url}</url>
</configuration>
</plugin>
</plugins>
</build>
<distributionManagement>
<repository>
<id>transport</id>
<url>http://localhost:8080/manager/text/deploy?path=/transport</url>
</repository>
</distributionManagement>
</project>
这是我的tomcat-users.xml
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user username="tomcat" password="tomcat" roles="standard,manager-gui,manager-script"/>
答案 0 :(得分:1)
将此添加到您的项目pom.xml文件中
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://localhost:8080/manager/text</url>
<server>tomcat</server>
<username>tomcat</username>
<password>tomcat</password>
</configuration>
</plugin>