Spring Boot未从IntelliJ部署WAR

时间:2018-07-06 14:59:01

标签: java spring-boot gradle intellij-idea build.gradle

我正在尝试将我的第一个Spring Boot应用程序部署到WAR文件,但无法正常工作。没有显示错误,但也找不到任何WAR文件。 我已经按照Spring Boot documentation以及整个StackOverflow上的所有步骤进行了操作。这些是

步骤1:我扩展了SpringBootServletInitializer

@SpringBootApplication
public class SpringBoot1Application extends SpringBootServletInitializer
{

    public static void main(String[] args) throws Exception
    {
        SpringApplication.run(SpringBoot1Application.class, args);
    }

}

步骤2:在build.gradle文件中添加了apply plugin: 'war'和依赖项

buildscript {
    ext {
        springBootVersion = '2.0.3.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'war'

group = 'com.ranadepto'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

repositories {
    mavenCentral()
}


dependencies {
    compile('org.springframework.boot:spring-boot-starter-data-jpa')
    compile('org.springframework.boot:spring-boot-starter-web')
    runtime('org.springframework.boot:spring-boot-devtools')
    runtime('mysql:mysql-connector-java')
    testCompile('org.springframework.boot:spring-boot-starter-test')
    provided 'org.springframework.boot:spring-boot-starter-tomcat'
    providedCompile 'javax.servlet:javax.servlet-api:3.1.0'

}

war {
    baseName = 'SpringBoot1'
}

我还包括控制台输出消息:

 :: Spring Boot ::        (v2.0.3.RELEASE)

2018-07-06 20:50:49.322  INFO 3489 --- [  restartedMain] c.r.SpringBoot1.SpringBoot1Application   : Starting SpringBoot1Application on Rana-Depto-MacBook-Pro.local with PID 3489 (/Users/ranadepto/Desktop/SpringBoot1/out/production/classes started by ranadepto in /Users/ranadepto/Desktop/SpringBoot1)
2018-07-06 20:50:49.324  INFO 3489 --- [  restartedMain] c.r.SpringBoot1.SpringBoot1Application   : No active profile set, falling back to default profiles: default
2018-07-06 20:50:49.375  INFO 3489 --- [  restartedMain] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@7acf6bce: startup date [Fri Jul 06 20:50:49 BDT 2018]; root of context hierarchy
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (file:/Users/ranadepto/.gradle/caches/modules-2/files-2.1/org.springframework/spring-core/5.0.7.RELEASE/54b731178d81e66eca9623df772ff32718208137/spring-core-5.0.7.RELEASE.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2018-07-06 20:50:50.215  INFO 3489 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$f69149ff] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-07-06 20:50:50.461  INFO 3489 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2018-07-06 20:50:50.476  INFO 3489 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2018-07-06 20:50:50.477  INFO 3489 --- [  restartedMain] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.31
2018-07-06 20:50:50.480  INFO 3489 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/Users/ranadepto/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.]
2018-07-06 20:50:50.527  INFO 3489 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-07-06 20:50:50.527  INFO 3489 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1157 ms
2018-07-06 20:50:50.612  INFO 3489 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
2018-07-06 20:50:50.615  INFO 3489 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-07-06 20:50:50.615  INFO 3489 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-07-06 20:50:50.615  INFO 3489 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-07-06 20:50:50.615  INFO 3489 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2018-07-06 20:50:50.710  INFO 3489 --- [  restartedMain] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2018-07-06 20:50:50.841  INFO 3489 --- [  restartedMain] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2018-07-06 20:50:50.866  INFO 3489 --- [  restartedMain] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2018-07-06 20:50:50.873  INFO 3489 --- [  restartedMain] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
    name: default
    ...]
2018-07-06 20:50:50.908  INFO 3489 --- [  restartedMain] org.hibernate.Version                    : HHH000412: Hibernate Core {5.2.17.Final}
2018-07-06 20:50:50.909  INFO 3489 --- [  restartedMain] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
2018-07-06 20:50:50.931  INFO 3489 --- [  restartedMain] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2018-07-06 20:50:50.995  INFO 3489 --- [  restartedMain] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect
2018-07-06 20:50:51.305  INFO 3489 --- [  restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2018-07-06 20:50:51.523  INFO 3489 --- [  restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-07-06 20:50:51.682  INFO 3489 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@7acf6bce: startup date [Fri Jul 06 20:50:49 BDT 2018]; root of context hierarchy
2018-07-06 20:50:51.700  WARN 3489 --- [  restartedMain] aWebConfiguration$JpaWebMvcConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2018-07-06 20:50:51.722  INFO 3489 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/reports],methods=[GET]}" onto public java.util.List<com.ranadepto.SpringBoot1.ReportModel> com.ranadepto.SpringBoot1.ReportController.getAllReports()
2018-07-06 20:50:51.723  INFO 3489 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/reports/{id}],methods=[GET]}" onto public com.ranadepto.SpringBoot1.ReportModel com.ranadepto.SpringBoot1.ReportController.getReportById(java.lang.String)
2018-07-06 20:50:51.724  INFO 3489 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/reports],methods=[POST]}" onto public com.ranadepto.SpringBoot1.ReportModel com.ranadepto.SpringBoot1.ReportController.createReport(com.ranadepto.SpringBoot1.ReportModel)
2018-07-06 20:50:51.724  INFO 3489 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/reports/{id}],methods=[PUT]}" onto public com.ranadepto.SpringBoot1.ReportModel com.ranadepto.SpringBoot1.ReportController.updateReport(java.lang.String,com.ranadepto.SpringBoot1.ReportModel)
2018-07-06 20:50:51.724  INFO 3489 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/reports/{id}],methods=[DELETE]}" onto public org.springframework.http.ResponseEntity<?> com.ranadepto.SpringBoot1.ReportController.deleteReport(java.lang.String)
2018-07-06 20:50:51.726  INFO 3489 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-07-06 20:50:51.726  INFO 3489 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-07-06 20:50:51.746  INFO 3489 --- [  restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-07-06 20:50:51.746  INFO 3489 --- [  restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-07-06 20:50:51.921  INFO 3489 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2018-07-06 20:50:51.942  INFO 3489 --- [  restartedMain] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2018-07-06 20:50:51.943  INFO 3489 --- [  restartedMain] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'dataSource' has been autodetected for JMX exposure
2018-07-06 20:50:51.947  INFO 3489 --- [  restartedMain] o.s.j.e.a.AnnotationMBeanExporter        : Located MBean 'dataSource': registering with JMX server as MBean [com.zaxxer.hikari:name=dataSource,type=HikariDataSource]
2018-07-06 20:50:51.972  INFO 3489 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2018-07-06 20:50:51.976  INFO 3489 --- [  restartedMain] c.r.SpringBoot1.SpringBoot1Application   : Started SpringBoot1Application in 2.93 seconds (JVM running for 3.809)

最后是IntelliJ目录层次结构的屏幕截图:

enter image description here

我花了一个小时在网络上进行调试和搜索,最后在这里遇到一个问题。请帮我解决这个问题。

0 个答案:

没有答案