错误是:
/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
我尝试开始但是在那些输出之后,它关闭了。我用spring initializr。我只想制作一个小型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
答案 0 :(得分:17)
我没有看到任何明显错误的东西。我有一个应用程序,我同时在不同的环境中部署为jar和war(它们只有包装不同);我有一个ServletInitializer
等同于你的,它的工作没有问题,只有一个主要区别。
我使用带有spring-boot:run
的maven run配置作为&#34;命令行&#34;值。有了这个我只能改变pom来反映jar或战争,跑步和去。在来回切换并使用在app类中调用main
的配置时,我遇到了问题。例如,为了好玩,我只是运行了jar包装并运行main
的应用实例。甚至不会发射。这是在使用我上面提到的maven配置打包并启动它之后。
我建议从创建maven运行配置开始,看看结果是什么。这是Intellij的方法,因此您不必使用命令行界面。
+
。spring-boot:run
添加到&#34;命令行&#34;条目。我不是eclipse / sts用户,但我确信有类似的方法。
答案 1 :(得分:8)
显然,您要将应用程序打包为war
,这很好,但问题是您通过main
课程中的InternetMovieDatabaseApplication
方法运行应用程序。相反,您应该将应用程序部署到独立Servlet容器,例如 Tomcat 或 Jetty ,或者使用{{1}运行应用程序}命令。
如果将您的应用程序打包为mvn spring-boot:run
存档并不是一项严格的要求,我建议制作jar,而不是战争。为此,请先删除war
中的packaging
:
pom.xml
然后删除<packaging>war</packaging>
依赖项:
spring-boot-starter-tomcat
最后删除<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
课程并在ServletInitializer
课程中运行main
方法。
答案 2 :(得分:0)
我认为您不需要ServletInitializer
带InternetMovieDatabaseApplication
注释的@SpringBootApplication
就足够了。
答案 3 :(得分:0)
尽管答案已经被接受,但这仍然可能会有所帮助:
您是要从Intellij的“运行”菜单中运行应用程序,还是通过右键单击并在定义了main的类上运行并遇到上述问题,并且该应用程序可以从命令行正常运行?
如果是上述情况,我看到您的pom.xml具有提供范围的依赖项。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
从intellij中的“运行”菜单运行应用程序时,默认情况下不提供具有提供范围的依赖项。
要解决此问题,
转到“运行”菜单->“编辑配置”,然后选择“包含” 提供范围的依赖项
然后尝试再次运行。这应该可以解决问题。
祝你好运。
答案 4 :(得分:-1)
我遇到了这个问题,亲爱的人发现了这种不良行为:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>
答案 5 :(得分:-1)
我认为您忘记在pom.xml的属性中添加主类
<properties>
<start-class>org.infoowl.InternetMovieDatabaseApplication</start-class>
<java.version>1.8</java.version>
</properties>
并按照以下步骤修改您的班级:
@SpringBootApplication
public class InternetMovieDatabaseApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(DemoApplication.class);
}
public static void main(String[] args) {
SpringApplication.run(InternetMovieDatabaseApplication.class, args);
}
}
并打开命令控制台,执行:
mvn clean package
然后,将war
部署到Tomcat demo here