私はspringブート、gradle、tomcatを使ってWebアプリケーションを実装しようとしています。私は次のJavaクラスを持っています。私がTomcatを実行すると、Tomcatが起動しますが、実行されません...私はgradleとspringでかなり新しいです。何か明白なことを尋ねると申し訳ありません。Spring + gradle + tomcat web appが動作しない
何が問題になりますか?
Application.java:
@SpringBootApplication
public class Application extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
public static void main(String[] args) throws Exception {
ApplicationContext ctx = SpringApplication.run(Application.class, args);
}
Build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.3.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'war'
version = '1.0-SNAPSHOT'
buildDir = 'target'
jar {
baseName = rootProject.name
}
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile("org.springframework.boot:spring-boot-starter-data-jpa:1.2.5.RELEASE")
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-actuator")
compile("org.postgresql:postgresql:9.4-1201-jdbc41")
compile("org.springframework:spring-jdbc:4.2.4.RELEASE")
compile("com.fasterxml.jackson.core:jackson-databind")
compile("org.liquibase:liquibase-core:3.3.3")
compile("org.springframework.boot:spring-boot-starter-data-mongodb")
compile 'org.springframework.boot:spring-boot-starter-thymeleaf'
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
testCompile("junit:junit")
}
bootRepackage {
mainClass = 'theproject.src.main.java.tutorialDatabaseServer.Application'
}
エラーは次のとおりです。
C:\onfocus-web\apache-tomcat-8.5.11\bin\catalina.bat run
[2017-06-30 08:00:50,688] Artifact unnamed: Server is not connected. Deploy is not available.
Using CATALINA_BASE: "C:\Users\Edu\.IntelliJIdea14\system\tomcat\Unnamed_tutorial-database-service_6"
Using CATALINA_HOME: "C:\onfocus-web\apache-tomcat-8.5.11"
Using CATALINA_TMPDIR: "C:\onfocus-web\apache-tomcat-8.5.11\temp"
Using JRE_HOME: "C:\Program Files\Java\jre1.8.0_111"
Using CLASSPATH: "C:\onfocus-web\apache-tomcat-8.5.11\bin\bootstrap.jar;C:\onfocus-web\apache-tomcat-8.5.11\bin\tomcat-juli.jar"
30-Jun-2017 20:00:52.492 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/8.5.11
30-Jun-2017 20:00:52.497 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Jan 10 2017 21:02:52 UTC
30-Jun-2017 20:00:52.498 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 8.5.11.0
30-Jun-2017 20:00:52.498 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Windows 7
30-Jun-2017 20:00:52.498 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 6.1
30-Jun-2017 20:00:52.498 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
30-Jun-2017 20:00:52.498 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: C:\Program Files\Java\jre1.8.0_111
30-Jun-2017 20:00:52.499 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_111-b14
30-Jun-2017 20:00:52.499 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
30-Jun-2017 20:00:52.499 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:\Users\Edu\.IntelliJIdea14\system\tomcat\Unnamed_tutorial-database-service_6
30-Jun-2017 20:00:52.499 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: C:\onfocus-web\apache-tomcat-8.5.11
30-Jun-2017 20:00:52.500 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Users\Edu\.IntelliJIdea14\system\tomcat\Unnamed_tutorial-database-service_6\conf\logging.properties
30-Jun-2017 20:00:52.500 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
30-Jun-2017 20:00:52.500 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote=
30-Jun-2017 20:00:52.500 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.port=1099
30-Jun-2017 20:00:52.500 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.ssl=false
30-Jun-2017 20:00:52.501 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.authenticate=false
30-Jun-2017 20:00:52.501 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.rmi.server.hostname=127.0.0.1
30-Jun-2017 20:00:52.501 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
30-Jun-2017 20:00:52.501 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
30-Jun-2017 20:00:52.501 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Users\Edu\.IntelliJIdea14\system\tomcat\Unnamed_tutorial-database-service_6
30-Jun-2017 20:00:52.501 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=C:\onfocus-web\apache-tomcat-8.5.11
30-Jun-2017 20:00:52.501 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=C:\onfocus-web\apache-tomcat-8.5.11\temp
30-Jun-2017 20:00:52.502 INFORMACIÓN [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent La biblioteca nativa de Apache Tomcat basada en ARP que permite un rendimiento óptimo en entornos de desarrollo no ha sido hallada en java.library.path: C:\Program Files\Java\jre1.8.0_111\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\Java\jdk1.8.0_20\bin;C:\Program Files (x86)\Liquid Technologies\Liquid XML Studio 2009\XmlDataBinder7\Redist7\cpp\win32\bin;%ANT_HOME%\bin;C:\onfocus-web\apache-tomcat-8.5.11\bin;%AXIS2_HOME%\bin;C:\Program Files\Java\jdk1.8.0_111\bin;%JRE_HOME%\bin;C:\Program Files (x86)\WinSCP\;C:\Program Files\nodejs\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\Skype\Phone\;C:\Program Files\PostgreSQL\pg95\bin;C:\Program Files\Git\cmd;C:\Program Files (x86)\Java\jre1.8.0_20\bin\javaw.exe;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\Java\jdk1.8.0_20\bin;C:\Program Files (x86)\Liquid Technologies\Liquid XML Studio 2009\XmlDataBinder7\Redist7\cpp\win32\bin;%ANT_HOME%\bin;C:\onfocus-web\apache-tomcat-8.5.11\bin;%AXIS2_HOME%\bin;C:\Program Files\Java\jdk1.8.0_111\bin;%JRE_HOME%\bin;C:\Program Files (x86)\WinSCP\;C:\Program Files\nodejs\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\Skype\Phone\;C:\Program Files\PostgreSQL\pg95\bin;C:\Program Files\Git\cmd;C:\Program Files (x86)\apache-ant-1.9.4\bin;C:\onfocus-web\apache-tomcat-8.5.11\bin;C:\Program Files (x86)\axis2-1.6.2\bin;C:\Program Files\Java\jdk1.8.0_111\bin;C:\Program Files\Java\jre1.8.0_111\bin;C:\Users\Edu\AppData\Roaming\npm;.
30-Jun-2017 20:00:52.796 INFORMACIÓN [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
30-Jun-2017 20:00:52.824 INFORMACIÓN [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
30-Jun-2017 20:00:52.827 INFORMACIÓN [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
30-Jun-2017 20:00:52.830 INFORMACIÓN [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
30-Jun-2017 20:00:52.831 INFORMACIÓN [main] org.apache.catalina.startup.Catalina.load Initialization processed in 868 ms
30-Jun-2017 20:00:52.864 INFORMACIÓN [main] org.apache.catalina.core.StandardService.startInternal Arrancando servicio Catalina
30-Jun-2017 20:00:52.864 INFORMACIÓN [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.11
30-Jun-2017 20:00:52.878 INFORMACIÓN [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [http-nio-8080]
30-Jun-2017 20:00:52.891 INFORMACIÓN [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [ajp-nio-8009]
30-Jun-2017 20:00:52.894 INFORMACIÓN [main] org.apache.catalina.startup.Catalina.start Server startup in 63 ms
Connected to server
[2017-06-30 08:00:53,212] Artifact unnamed: Artifact is being deployed, please wait...
[2017-06-30 08:00:53,724] Artifact unnamed: Artifact is deployed successfully
[2017-06-30 08:00:53,724] Artifact unnamed: Deploy took 512 milliseconds
30-Jun-2017 20:01:02.879 INFORMACIÓN [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Despliegue del directorio C:\onfocus-web\apache-tomcat-8.5.11\webapps\manager de la aplicación web
30-Jun-2017 20:01:02.937 INFORMACIÓN [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\onfocus-web\apache-tomcat-8.5.11\webapps\manager has finished in 57 ms
感謝します。
エラーは何ですか? Tomcatが起動され、ログに基づいてアプリがデプロイされます。 – CrazyCoder
なぜあなたはtomcatがあなたのアプリを起動するはずだと思いますか?あなたは戦争を起こしてそれをTomcatに配備しましたか?スプリングブートアプリケーションを起動する慣習的な方法は、harを生成し、そのjarを実行することです。このjarは、それ自体が埋め込まれたtomcatコンテナを起動します。なぜあなたはそれをしないのですか? –