0
我試圖在Tomcat中部署一個使用springboot生成的戰爭,在這個戰鬥中我已經成功了,但是這次卻弄不清楚什麼是錯誤的。在Tomcat的Springboot戰爭不起作用
最重要的代碼添加:
config/AppConfig
@Configuration
@EnableTransactionManagement
@Component
//@EnableWebMvc
@ComponentScan("com.singleuseapps")
public class AppConfig {
LaptopsApplication
@SpringBootApplication
@ComponentScan(basePackageClasses = {AppConfig.class,LaptopsApplication.class})
public class LaptopsApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(LaptopsApplication.class);
}
public static void main(String[] args) {
SpringApplication.run(LaptopsApplication.class, args);
}
build.gradle
buildscript {
ext {
springBootVersion = '1.4.2.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'idea'
apply plugin: 'war'
springBoot{
executable = true
}
jar {
baseName = 'laptops'
}
war {
baseName = 'laptops'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile 'org.hibernate:hibernate-core:5.0.9.Final'
compile("com.h2database:h2")
testCompile('org.springframework.boot:spring-boot-starter-test')
compile 'javax.servlet:javax.servlet-api:3.1.0'
compile 'org.javassist:javassist:3.15.0-GA'
compile 'mysql:mysql-connector-java:5.1.31'
compile 'commons-dbcp:commons-dbcp:1.4'
compile('org.springframework.boot:spring-boot-starter-jdbc')
providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
compileOnly "org.projectlombok:lombok:1.16.10"
compile "io.springfox:springfox-swagger2:2.6.0"
compile 'io.springfox:springfox-swagger-ui:2.6.0'
compile 'com.sun.mail:javax.mail'
compile('org.springframework.boot:spring-boot-starter-mail')
}
希望有人得到我爲什麼失敗。
[編輯]
Line在catalina.out的
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.singleuseapps.LaptopsApplication]; nested exception is java.io.FileNotFoundException: class path resource [com/singleuseapps/cart/TestMailController.class] cannot be opened because it does not exist
你應該給予確切的錯誤 – davidxxx
我得到在tomcat中測試端點時使用的404是 – Stefan
而您在部署階段沒有錯誤? – davidxxx