启动后弹簧启动停止
错误包括:
/usr/lib/jvm/java-8-oracle/bin/java -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:40745,suspend=y,server=n -Dspring.output.ansi.enabled=always -Dfile.encoding=UTF-8 -classpath /usr/lib/jvm/java-8-oracle/jre/lib/charsets.jar:/usr/lib/jvm/java-8-oracle/jre/lib/deploy.jar:/usr/lib/jvm/java-8-oracle/jre/lib/ext/cldrdata.jar:/usr/lib/jvm/java-8-oracle/jre/lib/ext/dnsns.jar:/usr/lib/jvm/java-8-oracle/jre/lib/ext/jaccess.jar:/usr/lib/jvm/java-8-oracle/jre/lib/ext/jfxrt.jar:/usr/lib/jvm/java-8-oracle/jre/lib/ext/localedata.jar:/usr/lib/jvm/java-8-oracle/jre/lib/ext/nashorn.jar:/usr/lib/jvm/java-8-oracle/jre/lib/ext/sunec.jar:/usr/lib/jvm/java-8-oracle/jre/lib/ext/sunjce_provider.jar:/usr/lib/jvm/java-8-oracle/jre/lib/ext/sunpkcs11.jar:/usr/lib/jvm/java-8-oracle/jre/lib/ext/zipfs.jar:/usr/lib/jvm/java-8-oracle/jre/lib/javaws.jar:/usr/lib/jvm/java-8-oracle/jre/lib/jce.jar:/usr/lib/jvm/java-8-oracle/jre/lib/jfr.jar:/usr/lib/jvm/java-8-oracle/jre/lib/jfxswt.jar:/usr/lib/jvm/java-8-oracle/jr main] o.s.b.c.c.ConfigFileApplicationListener : Skipped (empty) config file 'file:./application.properties' for profile default
2016-03-25 23:43:41.426 DEBUG 18169 --- [ main] o.s.b.c.c.ConfigFileApplicationListener : Skipped (empty) config file 'classpath:/application.properties' for profile default
2016-03-25 23:43:41.460 INFO 18169 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@3738449f: startup date [Fri Mar 25 23:43:41 EET 2016]; root of context hierarchy
2016-03-25 23:43:44.256 DEBUG 18169 --- [ main] o.s.b.a.AutoConfigurationPackages : @EnableAutoConfiguration was declared on a class in the package 'org.infoowl'. Automatic @Repository and @Entity scanning is enabled.
2016-03-25 23:43:46.084 INFO 18169 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2016-03-25 23:43:46.136 INFO 18169 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2016-03-25 23:43:46.306 INFO 18169 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {4.3.11.Final}
2016-03-25 23:43:46.309 INFO 18169 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2016-03-25 23:43:46.323 INFO 18169 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2016-03-25 23:43:47.042 INFO 18169 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
2016-03-25 23:43:47.841 INFO 18169 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
2016-03-25 23:43:48.085 INFO 18169 --- [ main] o.h.h.i.ast.ASTQueryTranslatorFactory : HHH000397: Using ASTQueryTranslatorFactory
2016-03-25 23:43:48.971 INFO 18169 --- [ main] org.hibernate.tool.hbm2ddl.SchemaUpdate : HHH000228: Running hbm2ddl schema update
2016-03-25 23:43:48.972 INFO 18169 --- [ main] org.hibernate.tool.hbm2ddl.SchemaUpdate : HHH000102: Fetching database metadata
2016-03-25 23:43:48.988 INFO 18169 --- [ main] org.hibernate.tool.hbm2ddl.SchemaUpdate : HHH000396: Updating schema
2016-03-25 23:43:49.111 INFO 18169 --- [ main] o.hibernate.tool.hbm2ddl.TableMetadata : HHH000261: Table found: movies.movie
2016-03-25 23:43:49.112 INFO 18169 --- [ main] o.hibernate.tool.hbm2ddl.TableMetadata : HHH000037: Columns: [actor, id, title]
2016-03-25 23:43:49.112 INFO 18169 --- [ main] o.hibernate.tool.hbm2ddl.TableMetadata : HHH000108: Foreign keys: []
2016-03-25 23:43:49.112 INFO 18169 --- [ main] o.hibernate.tool.hbm2ddl.TableMetadata : HHH000126: Indexes: [primary]
2016-03-25 23:43:49.113 INFO 18169 --- [ main] org.hibernate.tool.hbm2ddl.SchemaUpdate : HHH000232: Schema update complete
2016-03-25 23:43:50.698 INFO 18169 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2016-03-25 23:43:50.727 DEBUG 18169 --- [ main] utoConfigurationReportLoggingInitializer :
=========================
AUTO-CONFIGURATION REPORT
=========================
Positive matches:
-----------------
HazelcastJpaDependencyAutoConfiguration did not match
- required @ConditionalOnClass classes not found: com.hazelcast.core.HazelcastInstance (OnClassCondition)
HornetQAutoConfiguration did not match
- required @ConditionalOnClass classes not found: javax.jms.ConnectionFactory,org.hornetq.api.jms.HornetQJMSClient (OnClassCondition)
HttpEncodingAutoConfiguration did not match
- required @ConditionalOnClass classes not found: org.springframework.web.filter.CharacterEncodingFilter (OnClassCondition)
HypermediaAutoConfiguration did not match
- required @ConditionalOnClass classes not found: org.springframework.hateoas.Resource,org.springframework.plugin.core.Plugin (OnClassCondition)
InfinispanCacheConfiguration did not match
- required @ConditionalOnClass classes not found: org.infinispan.spring.provider.SpringEmbeddedCacheManager (OnClassCondition)
IntegrationAutoConfiguration did not match
- required @ConditionalOnClass classes not found: org.springframework.integration.config.EnableIntegration (OnClassCondition)
JCacheCacheConfiguration did not match
- required @ConditionalOnClass classes not found: javax.cache.Caching,org.springframework.cache.jcache.JCacheCacheManager (OnClassCondition)
JacksonAutoConfiguration.JodaDateTimeJacksonConfiguration did not match
- required @ConditionalOnClass classes not found: org.joda.time.DateTime,com.fasterxml.jackson.datatype.joda.ser.DateTimeSerializer,com.fasterxml.jackson.datatype.joda.cfg.JacksonJodaDateFormat (OnClassCondition)
JacksonAutoConfiguration.ParameterNamesModuleConfiguration did not match
- required @ConditionalOnClass classes not found: com.fasterxml.jackson.module.paramnames.ParameterNamesModule (OnClassCondition)
JacksonHttpMessageConvertersConfiguration.MappingJackson2XmlHttpMessageConverterConfiguration did not match
- required @ConditionalOnClass classes not found: com.fasterxml.jackson.dataformat.xml.XmlMapper (OnClassCondition)
JerseyAutoConfiguration did not match
- required @ConditionalOnClass classes not found: org.glassfish.jersey.server.spring.SpringComponentProvider,javax.servlet.ServletRegistration (OnClassCondition)
JmsAutoConfiguration did not match
- required @ConditionalOnClass classes not found: org.springframework.jms.core.JmsTemplate (OnClassCondition)
JndiConnectionFactoryAutoConfiguration did not match
- required @ConditionalOnClass classes not found: org.springframework.jms.core.JmsTemplate (OnClassCondition)
JndiDataSourceAutoConfiguration did not match
- @ConditionalOnClass classes found: javax.sql.DataSource,org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType (OnClassCondition)
- @ConditionalOnProperty missing required properties spring.datasource.jndi-name (OnPropertyCondition)
JndiJtaConfiguration did not match
- @ConditionalOnClass classes found: org.springframework.transaction.jta.JtaTransactionManager (OnClassCondition)
- JNDI environment is not available (OnJndiCondition)
JooqAutoConfiguration did not match
- required @ConditionalOnClass classes not found: org.jooq.DSLContext (OnClassCondition)
JpaBaseConfiguration.JpaWebConfiguration did not match
- @ConditionalOnClass classes found: org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter (OnClassCondition)
- not a web application (OnWebApplicationCondition)
LinkedInAutoConfiguration did not match
- required @ConditionalOnClass classes not found: org.springframework.social.config.annotation.SocialConfigurerAdapter,org.springframework.social.linkedin.connect.LinkedInConnectionFactory (OnClassCondition)
LiquibaseAutoConfiguration did not match
- required @ConditionalOnClass classes not found: liquibase.integration.spring.SpringLiquibase (OnClassCondition)
MailSenderAutoConfiguration did not match
- required @ConditionalOnClass classes not found: javax.mail.internet.MimeMessage (OnClassCondition)
MailSenderValidatorAutoConfiguration did not match
- @ConditionalOnProperty missing required properties spring.mail.test-connection (OnPropertyCondition)
MessageSourceAutoConfiguration did not match
- No bundle found for spring.messages.basename: messages (MessageSourceAutoConfiguration.ResourceBundleCondition)
MongoAutoConfiguration did not match
- required @ConditionalOnClass classes not found: com.mongodb.MongoClient (OnClassCondition)
MongoDataAutoConfiguration did not match
- required @ConditionalOnClass classes not found: com.mongodb.Mongo,org.springframework.data.mongodb.core.MongoTemplate (OnClassCondition)
MongoRepositoriesAutoConfiguration did not match
- required @ConditionalOnClass classes not found: com.mongodb.Mongo,org.springframework.data.mongodb.repository.MongoRepository (OnClassCondition)
MultipartAutoConfiguration did not match
- required @ConditionalOnClass classes not found: javax.servlet.Servlet,javax.servlet.MultipartConfigElement (OnClassCondition)
MustacheAutoConfiguration did not match
- required @ConditionalOnClass classes not found: com.samskivert.mustache.Mustache (OnClassCondition)
OAuth2AutoConfiguration did not match
- required @ConditionalOnClass classes not found: org.springframework.security.oauth2.common.OAuth2AccessToken (OnClassCondition)
RabbitAutoConfiguration did not match
- required @ConditionalOnClass classes not found: org.springframework.amqp.rabbit.core.RabbitTemplate,com.rabbitmq.client.Channel (OnClassCondition)
ReactorAutoConfiguration did not match
- required @ConditionalOnClass classes not found: reactor.spring.context.config.EnableReactor,reactor.Environment (OnClassCondition)
RedisAutoConfiguration did not match
- required @ConditionalOnClass classes not found: org.springframework.data.redis.connection.jedis.JedisConnection,org.springframework.data.redis.core.RedisOperations,redis.clients.jedis.Jedis (OnClassCondition)
RepositoryRestMvcAutoConfiguration did not match
- required @ConditionalOnClass classes not found: org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration (OnClassCondition)
SecurityAutoConfiguration did not match
- required @ConditionalOnClass classes not found: org.springframework.security.authentication.AuthenticationManager,org.springframework.security.config.annotation.authentication.configurers.GlobalAuthenticationConfigurerAdapter (OnClassCondition)
SecurityFilterAutoConfiguration did not match
- required @ConditionalOnClass classes not found: org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer,org.springframework.security.config.http.SessionCreationPolicy (OnClassCondition)
SendGridAutoConfiguration did not match
- required @ConditionalOnClass classes not found: com.sendgrid.SendGrid (OnClassCondition)
ServerPropertiesAutoConfiguration did not match
- not a web application (OnWebApplicationCondition)
SessionAutoConfiguration did not match
- required @ConditionalOnClass classes not found: org.springframework.session.Session (OnClassCondition)
SitePreferenceAutoConfiguration did not match
- required @ConditionalOnClass classes not found: org.springframework.mobile.device.site.SitePreferenceHandlerInterceptor,org.springframework.mobile.device.site.SitePreferenceHandlerMethodArgumentResolver (OnClassCondition)
SocialWebAutoConfiguration did not match
- required @ConditionalOnClass classes not found: org.springframework.social.connect.web.ConnectController,org.springframework.social.config.annotation.SocialConfigurerAdapter (OnClassCondition)
SolrAutoConfiguration did not match
- required @ConditionalOnClass classes not found: org.apache.solr.client.solrj.impl.HttpSolrServer,org.apache.solr.client.solrj.impl.CloudSolrServer,org.apache.solr.common.cloud.HashPartitioner (OnClassCondition)
SolrRepositoriesAutoConfiguration did not match
- required @ConditionalOnClass classes not found: org.apache.solr.client.solrj.SolrServer,org.springframework.data.solr.repository.SolrRepository (OnClassCondition)
SpringApplicationAdminJmxAutoConfiguration did not match
- @ConditionalOnProperty missing required properties spring.application.admin.enabled (OnPropertyCondition)
SpringDataWebAutoConfiguration did not match
- @ConditionalOnClass classes found: org.springframework.data.web.PageableHandlerMethodArgumentResolver,org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter (OnClassCondition)
- not a web application (OnWebApplicationCondition)
ThymeleafAutoConfiguration did not match
- required @ConditionalOnClass classes not found: org.thymeleaf.spring4.SpringTemplateEngine (OnClassCondition)
TwitterAutoConfiguration did not match
- required @ConditionalOnClass classes not found: org.springframework.social.config.annotation.SocialConfigurerAdapter,org.springframework.social.twitter.connect.TwitterConnectionFactory (OnClassCondition)
VelocityAutoConfiguration did not match
- required @ConditionalOnClass classes not found: org.apache.velocity.app.VelocityEngine,org.springframework.ui.velocity.VelocityEngineFactory (OnClassCondition)
WebMvcAutoConfiguration did not match
- required @ConditionalOnClass classes not found: javax.servlet.Servlet,org.springframework.web.servlet.DispatcherServlet (OnClassCondition)
WebSocketAutoConfiguration did not match
- required @ConditionalOnClass classes not found: javax.servlet.Servlet,javax.websocket.server.ServerContainer (OnClassCondition)
WebSocketMessagingAutoConfiguration did not match
- required @ConditionalOnClass classes not found: org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer (OnClassCondition)
XADataSourceAutoConfiguration did not match
- @ConditionalOnClass classes found: javax.sql.DataSource,javax.transaction.TransactionManager,org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType (OnClassCondition)
- @ConditionalOnBean (types: org.springframework.boot.jta.XADataSourceWrapper; SearchStrategy: all) found no beans (OnBeanCondition)
Exclusions:
-----------
None
Unconditional classes:
----------------------
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
org.springframework.boot.autoconfigure.context.ConfigurationPropertiesAutoConfiguration
2016-03-25 23:43:50.761 INFO 18169 --- [ main] o.i.InternetMovieDatabaseApplication : Started InternetMovieDatabaseApplication in 11.476 seconds (JVM running for 14.426)
2016-03-25 23:43:50.774 INFO 18169 --- [ Thread-2] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@3738449f: startup date [Fri Mar 25 23:43:41 EET 2016]; root of context hierarchy
2016-03-25 23:43:50.789 INFO 18169 --- [ Thread-2] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
2016-03-25 23:43:50.790 INFO 18169 --- [ Thread-2] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
Disconnected from the target VM, address: '127.0.0.1:40745', transport: 'socket'
Process finished with exit code 0
我尝试启动,但在这些输出之后,它关闭了。我用了弹簧初始化。我只想做一个小的REST API。
这是我的:pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.infoowl</groupId>
<artifactId>internetmoviedatabase</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>InternetMovieDatabase</name>
<description>Internet Movie Database Application</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
这是:application.properteis
spring.datasource.url=jdbc:mysql://localhost:3306/movies
spring.datasource.username=root
spring.datasource.password=
spring.jpa.hibernate.ddl-auto=update
server.port=8181
spring.jpa.database=MYSQL
spring.jpa.show-sql=true
InternetMovieDatabaseApplication
类:
package org.infoowl;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class InternetMovieDatabaseApplication {
public static void main(String[] args) {
SpringApplication.run(InternetMovieDatabaseApplication.class, args);
}
}
ServletInitializer
类:
package org.infoowl;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
public class ServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(InternetMovieDatabaseApplication.class);
}
}
这些是错误,如果我删除:ServletInitializer
2016-03-26 00:20:22.691 ERROR 20251 --- [ main] o.s.boot.SpringApplication : Application startup failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [org.infoowl.InternetMovieDatabaseApplication]; nested exception is java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.boot.context.web.SpringBootServletInitializer
at org.springframework.context.annotation.ConfigurationClassParser.parse(Configurplication.java:1191) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
at o
Caused by: java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.boot.context.web.SpringBootServletInitializer
at org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(StandardAnnotationMetadata.java:163) ~[spring-core-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:292) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:232) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at E.jar:4.2.5.RELEASE]
... 12 common frames omitted
Caused by: java.lang.NoClassDefFoundError: javax/servlet/ServletContext
at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_74]
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[na:1.8.0_74]
at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[na:1.8.0_74]
at org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(StandardAnnotationMetadata.java:152) ~[spring-core-4.2.5.RELEASE.jar:4.2.5.RELEASE]
... 16 common frames omitted
Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletContext
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.IU-144.4199.23/lib/idea_rt.jar]
Disconnected from the target VM, address: '127.0.0.1:42011', transport: 'socket'
Process finished with exit code 1