亲宝软件园·资讯

展开

pom.xml文件注入test测试依赖时报错

YangHT1024 人气:0

pom.xml文件注入test测试依赖时报错

报错:Failed to read artifact descriptor for org.springframework.boot:spring-boot-starter-test:jar:2.0.4.RELEASE

分析原因

有可能是默认版本太高

解决方法

降低版本

springboot中pom.xml之间的依赖

依赖关系 

parent(dependency springboot)  <---- common(parent parent)   
|<----admin(parent parent, dependency common)
|<----rest(parent parent, dependency common)
|<----chat(parent parent​​​​​​​, dependency common)
 <----portal(parent parent) 

所用到的技术

spring-boot
spring-boot-starter-thymeleaf
spring-boot-starter-data-redis
spring-boot-starter-data-jpa
spring-boot-starter-cache缓存支持
spring-boot-maven-plugin
 
maven-compiler-plugin
 
shiro-spring
shiro-web
shiro-ehcache
shiro-redis<!--redis缓存shiro-->
 
thymeleaf-extras-shiro
 
httpclient
netty-all
jackson-databind
 
druid
mysql-connector-java

json格式化类库:

fastjson
guava
jackson-annotations

Spring RESTful接口文档化:

springfox-swagger2
springfox-swagger-ui
nekohtml

talk is cheap , 详见配置文件

parent project 

<?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.yourproject</groupId>
    <artifactId>yourproject-parent</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>
 
    <!-- 集中定义依赖版本号与基本配置 -->
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
 
        <druid.version>1.0.29</druid.version>
        <fastjson.version>1.2.16</fastjson.version>
        <guava.version>19.0</guava.version>
        <shiro.version>1.3.2</shiro.version>
        <shiro.th.version>1.2.1</shiro.th.version>
        <shiro.redis.version>2.4.2.1-RELEASE</shiro.redis.version>
        <nekohtml.version>1.9.22</nekohtml.version>
        <fasterxml.version>2.8.0</fasterxml.version>
        <springfox.version>2.2.2</springfox.version>
    </properties>
 
    <dependencyManagement>
        <dependencies>
  <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-dependencies</artifactId>
      <version>2.0.5.RELEASE</version>
      <type>pom</type>
      <scope>import</scope>
  </dependency>
  <dependency>
      <groupId>com.alibaba</groupId>
      <artifactId>druid</artifactId>
      <version>${druid.version}</version>
  </dependency>
  <dependency>
      <groupId>org.apache.shiro</groupId>
      <artifactId>shiro-spring</artifactId>
      <version>${shiro.version}</version>
  </dependency>
  <dependency>
      <groupId>org.apache.shiro</groupId>
      <artifactId>shiro-web</artifactId>
      <version>${shiro.version}</version>
  </dependency>
  <dependency>
      <groupId>com.github.theborakompanioni</groupId>
      <artifactId>thymeleaf-extras-shiro</artifactId>
      <version>${shiro.th.version}</version>
  </dependency>
  <dependency>
      <groupId>org.apache.shiro</groupId>
      <artifactId>shiro-ehcache</artifactId>
      <version>${shiro.th.version}</version>
  </dependency>
  <dependency>
      <groupId>org.crazycake</groupId>
      <artifactId>shiro-redis</artifactId>
      <version>${shiro.redis.version}</version>
  </dependency>
  <dependency>
      <groupId>net.sourceforge.nekohtml</groupId>
      <artifactId>nekohtml</artifactId>
      <version>${nekohtml.version}</version>
  </dependency>
 
  <!--json格式化类库 -->
  <dependency>
      <groupId>com.alibaba</groupId>
      <artifactId>fastjson</artifactId>
      <version>${fastjson.version}</version>
  </dependency>
  <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>${guava.version}</version>
  </dependency>
  <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-annotations</artifactId>
      <version>${fasterxml.version}</version>
  </dependency>
  <!--Spring RESTful接口文档化 -->
  <dependency>
      <groupId>io.springfox</groupId>
      <artifactId>springfox-swagger2</artifactId>
      <version>${springfox.version}</version>
  </dependency>
  <dependency>
      <groupId>io.springfox</groupId>
      <artifactId>springfox-swagger-ui</artifactId>
      <version>${springfox.version}</version>
  </dependency>
        </dependencies>
    </dependencyManagement>
 
</project>

common项目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">
    <parent>
        <artifactId>yourproject-parent</artifactId>
        <groupId>com.yourproject</groupId>
        <version>1.0-SNAPSHOT</version>
        <relativePath>../yourproject-parent/pom.xml</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.yourproject</groupId>
    <artifactId>yourproject-common</artifactId> 
 
    <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-cache</artifactId>
        </dependency>
        <!--ehcache支持-->
        <dependency>
        <groupId>net.sf.ehcache</groupId>
        <artifactId>ehcache</artifactId>
        </dependency>
        <dependency>
  <groupId>mysql</groupId>
  <artifactId>mysql-connector-java</artifactId>
  <scope>runtime</scope>
        </dependency>
        <dependency>
  <groupId>com.alibaba</groupId>
  <artifactId>druid</artifactId>
        </dependency>
        <dependency>
  <groupId>net.sourceforge.nekohtml</groupId>
  <artifactId>nekohtml</artifactId>
        </dependency>
        <dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-test</artifactId>
  <scope>test</scope>
        </dependency>
        <!--json序列化支持-->
        <dependency>
  <groupId>com.alibaba</groupId>
  <artifactId>fastjson</artifactId>
        </dependency>
        <dependency>
  <groupId>com.google.guava</groupId>
  <artifactId>guava</artifactId>
        </dependency>
        <dependency>
  <groupId>com.fasterxml.jackson.core</groupId>
  <artifactId>jackson-annotations</artifactId>
        </dependency>
 
    </dependencies>
 
    <build>
        <finalName>yourproject-common</finalName>
        <plugins>
  <plugin>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-maven-plugin</artifactId>
  </plugin>
  <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <configuration>
<source>1.7</source>
<target>1.7</target>
      </configuration>
  </plugin>
        </plugins>
    </build>
 
</project>

admin project

<?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">
    <parent>
        <artifactId>yourproject-parent</artifactId>
        <groupId>com.yourproject</groupId>
        <version>1.0-SNAPSHOT</version>
        <relativePath>../yourproject-parent/pom.xml</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.yourproject</groupId>
    <artifactId>yourproject-admin</artifactId>
    <packaging>war</packaging> 
 
    <dependencies>
        <dependency>
  <groupId>com.yourproject</groupId>
  <artifactId>yourproject-common</artifactId>
  <version>1.0-SNAPSHOT</version>
        </dependency>
        <dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter</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-thymeleaf</artifactId>
        </dependency>
        <dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-test</artifactId>
  <scope>test</scope>
        </dependency>
        <!--热部署-->
        <dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-devtools</artifactId>
  <optional>true</optional>
        </dependency>
        <dependency>
  <groupId>org.apache.shiro</groupId>
  <artifactId>shiro-spring</artifactId>
        </dependency>
        <dependency>
  <groupId>org.apache.shiro</groupId>
  <artifactId>shiro-web</artifactId>
        </dependency>
        <dependency>
  <groupId>org.apache.shiro</groupId>
  <artifactId>shiro-ehcache</artifactId>
        </dependency>
        <dependency>
  <groupId>com.github.theborakompanioni</groupId>
  <artifactId>thymeleaf-extras-shiro</artifactId>
        </dependency>
        <!--redis缓存shiro-->
        <dependency>
  <groupId>org.crazycake</groupId>
  <artifactId>shiro-redis</artifactId>
        </dependency>
 
    </dependencies>
    <build>
        <plugins>
  <plugin>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-maven-plugin</artifactId>
      <configuration>
<fork>true</fork>
      </configuration>
  </plugin>
        </plugins>
    </build>
 
</project>

portal project

<?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">
    <parent>
        <artifactId>yourproject-parent</artifactId>
        <groupId>com.yourproject</groupId>
        <version>1.0-SNAPSHOT</version>
        <relativePath>../yourproject-parent/pom.xml</relativePath>
    </parent>
 
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.yourproject</groupId>
    <artifactId>yourproject-portal</artifactId>
    <packaging>war</packaging>
 
    <dependencies>
        <dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter</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-thymeleaf</artifactId>
        </dependency>
        <dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-test</artifactId>
  <scope>test</scope>
        </dependency>
 
        <dependency>
  <groupId>net.sourceforge.nekohtml</groupId>
  <artifactId>nekohtml</artifactId>
  <version>1.9.15</version>
        </dependency>
        <!-- httpclient -->
        <dependency>
  <groupId>org.apache.httpcomponents</groupId>
  <artifactId>httpclient</artifactId>
        </dependency>
    </dependencies>
 
</project>

rest project

<?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">
    <parent>
        <artifactId>yourproject-parent</artifactId>
        <groupId>com.yourproject</groupId>
        <version>1.0-SNAPSHOT</version>
        <relativePath>../yourproject-parent/pom.xml</relativePath>
    </parent>
 
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.yourproject</groupId>
    <artifactId>yourproject-rest</artifactId>
    <packaging>war</packaging>
 
    <dependencies>
 
    <dependency>
        <groupId>com.yourproject</groupId>
        <artifactId>yourproject-common</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>
        <dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter</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-test</artifactId>
  <scope>test</scope>
        </dependency>
        <!--Redis服务-->
        <dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>
        <!--生成文档-->
        <dependency>
  <groupId>io.springfox</groupId>
  <artifactId>springfox-swagger2</artifactId>
        </dependency>
        <dependency>
  <groupId>io.springfox</groupId>
  <artifactId>springfox-swagger-ui</artifactId>
        </dependency>
        <!--web Socket-->
        <dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-websocket</artifactId>
        </dependency>
        <dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-messaging</artifactId>
        </dependency>
    </dependencies>
</project>

chat project

<?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">
    <parent>
        <artifactId>yourproject-parent</artifactId>
        <groupId>com.yourproject</groupId>
        <version>1.0-SNAPSHOT</version>
        <relativePath>../yourproject-parent/pom.xml</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>
 
    <groupId>com.yourproject</groupId>
    <artifactId>yourproject-chat</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
 
    <dependencies>
        <dependency>
  <groupId>com.yourproject</groupId>
  <artifactId>yourproject-common</artifactId>
  <version>1.0-SNAPSHOT</version>
        </dependency>
        <dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-test</artifactId>
  <scope>test</scope>
        </dependency>
        <!--Redis服务-->
        <dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>
        <!--JSON序列化-->
        <dependency>
  <groupId>com.alibaba</groupId>
  <artifactId>fastjson</artifactId>
  <version>1.2.23</version>
        </dependency>
        <!--Netty-->
        <dependency>
  <groupId>io.netty</groupId>
  <artifactId>netty-all</artifactId>
  <version>4.1.6.Final</version>
        </dependency>
        <dependency>
  <groupId>com.fasterxml.jackson.core</groupId>
  <artifactId>jackson-databind</artifactId>
        </dependency>
    </dependencies>
</project>

以上为个人经验,希望能给大家一个参考,也希望大家多多支持。

加载全部内容

相关教程
猜你喜欢
用户评论