文章详情

短信预约-IT技能 免费直播动态提醒

请输入下面的图形验证码

提交验证

短信预约提醒成功

springboot中pom.xml文件注入test测试依赖时报错的解决

2024-04-02 19:55

关注

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>

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

阅读原文内容投诉

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

软考中级精品资料免费领

  • 历年真题答案解析
  • 备考技巧名师总结
  • 高频考点精准押题
  • 2024年上半年信息系统项目管理师第二批次真题及答案解析(完整版)

    难度     813人已做
    查看
  • 【考后总结】2024年5月26日信息系统项目管理师第2批次考情分析

    难度     354人已做
    查看
  • 【考后总结】2024年5月25日信息系统项目管理师第1批次考情分析

    难度     318人已做
    查看
  • 2024年上半年软考高项第一、二批次真题考点汇总(完整版)

    难度     435人已做
    查看
  • 2024年上半年系统架构设计师考试综合知识真题

    难度     224人已做
    查看

相关文章

发现更多好内容

猜你喜欢

AI推送时光机
位置:首页-资讯-后端开发
咦!没有更多了?去看看其它编程学习网 内容吧
首页课程
资料下载
问答资讯