2016-11-30 7 views
0

Ich versuche, einen Krieg mit Springboot in Tomcat, in dem ich bisher gelungen, aber nicht herausfinden, was falsch ist dieses Mal erzeugt generiert.Springboot Krieg in Tomcat funktioniert nicht

Der wichtigste Code hinzugefügt:

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') 
} 

Hoffe jemand bekommt, warum ich gescheitert bin.

[Bearbeiten]

Linie in 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 
+0

sollten Sie die genauen Fehler geben – davidxxx

+0

ich a 404 beim Testen des Endpunkts in Tomcat – Stefan

+0

Und Sie haben keinen Fehler in der Bereitstellungsphase? – davidxxx

Antwort

0

Sie sollten:

  • entfernen @Component von AppConfig (es ist bereits mit @Configuration kommentierten)
  • entfernen. configure method from LaptopsApplication, ist bereits mit @SpringBootApplication versehen und ist automatisch eine Konfigurationsklasse, die Sie nicht benötigen d es erneut hinzufügen
  • Stellen Sie sicher, Ihre Controller-Klasse in dem Paket durch Ihre zwei @ComponentScan Anmerkungen angegeben ist (Sie wahrscheinlich brauchen nur die eine auf Ihrer Haupt-App-Klasse)
+0

Ich habe es versucht, aber es löst meine Probleme nicht – Stefan

Verwandte Themen