SpringBoot启动报错 java.lang.NoClassDefFoundError: javax/validation/ValidationException

  在做Springboot项目时,环境搭建启动正常,但是过了几天之后再启动就报些莫名奇妙的错误,网上百度了一大推,都不能解决问题,最后发现是自己的maven仓库环境缺了些配置,重新配置maven的settings文件,在编译启动就正常了。

修改后的settings.xml

<?xml version="1.0" encoding="UTF-8"?>
<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>D:\Program Files\repository</localRepository>

  <pluginGroups>
  </pluginGroups>
  <proxies>
  </proxies>
  <mirrors>
    
    <mirror>
        <id>alimaven</id>
         <name>aliyun maven</name>
         <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
         <mirrorOf>central</mirrorOf>
    </mirror>
    <mirror>
         <id>central</id>
         <name>Maven Repository Switchboard</name>
         <url>http://repo1.maven.org/maven2/</url>
         <mirrorOf>central</mirrorOf>
    </mirror>
    <mirror>
         <id>repo2</id>
         <mirrorOf>central</mirrorOf>
         <name>Human Readable Name for this Mirror.</name>
         <url>http://repo2.maven.org/maven2/</url>
    </mirror>
    <mirror>
         <id>ibiblio</id>
         <mirrorOf>central</mirrorOf>
         <name>Human Readable Name for this Mirror.</name>
         <url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>
    </mirror>
    <mirror>
         <id>jboss-public-repository-group</id>
         <mirrorOf>central</mirrorOf>
         <name>JBoss Public Repository Group</name>
         <url>http://repository.jboss.org/nexus/content/groups/public</url>
    </mirror>
    <!-- 中央仓库在中国的镜像 -->
    <mirror>
         <id>maven.net.cn</id>
         <name>oneof the central mirrors in china</name>
         <url>http://maven.net.cn/content/groups/public/</url>
         <mirrorOf>central</mirrorOf>
    </mirror>
  </mirrors>
  <profiles>
    <profile>    
        <id>jdk-1.8</id>    
        <activation>    
          <activeByDefault>true</activeByDefault>    
          <jdk>1.8</jdk>    
        </activation>    
        <properties>    
            <maven.compiler.source>1.8</maven.compiler.source>    
            <maven.compiler.target>1.8</maven.compiler.target>    
            <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>    
        </properties>    
    </profile>
  </profiles>
  <!--
    <activeProfiles>
    <activeProfile>dev</activeProfile>
    </activeProfiles>
    -->
</settings>

 

最后在pom.xml文件中添加以下插件(结合个人项目看是否添加)

 <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.7</version>
         <dependencies>
                    <dependency>
                        <groupId>org.apache.maven.shared</groupId>
                        <artifactId>maven-filtering</artifactId>
                        <version>1.3</version>
                    </dependency>
         </dependencies>
</plugin>

 

总结:maven环境一定要配好,要不然以后做项目会报一些奇怪的问题。

posted @ 2020-12-07 12:59  donleo123  阅读(5893)  评论(0编辑  收藏  举报