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環境一定要配好,要不然以后做項目會報一些奇怪的問題。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM