赞
踩
《一眼就会系列》每天抽出一点时间巩固基础!同时学习最新知识(与时俱进)!罗列、简述、概括问题,让读者扫一眼就知道该如何处理。
其实就是配置文件和包的版本问题。
解决方法如下:(请放大并用超清观看)
java
build.gradle 配置文件:
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'idea'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
//jdbc
compile 'org.springframework.boot:spring-boot-starter-jdbc:2.5.3'
compile 'mysql:mysql-connector-java:8.0.28'
//json
compile 'com.alibaba:fastjson:1.2.39'
//spring
compile 'org.springframework.boot:spring-boot-starter-web:2.5.2'
/* log4j */
compile 'org.apache.logging.log4j:log4j-core:2.17.1'
compile 'org.apache.logging.log4j:log4j-api:2.17.1'
//swagger:
compile 'io.springfox:springfox-swagger2:3.0.0'
compile 'io.springfox:springfox-swagger-ui:3.0.0'
compile 'com.google.guava:guava:31.0.1-jre'
compile 'junit:junit:4.12'
}
jar {
String JarPathAll = ''
configurations.runtime.each {JarPathAll = JarPathAll + " lib\\"+it.name}
manifest {
attributes 'Main-Class': 'org.example.ApplicationStart'
attributes 'Class-Path': JarPathAll
}
}
test {
useJUnitPlatform()
}
ApplicationStart.java 启动文件:
package org.example;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
public class ApplicationStart {
public static void main(String[] args) {
SpringApplication.run(ApplicationStart.class);
}
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。