0
私はinbuild tomcatサーバーを使用して非常に基本的なスプリングブートサービスを構築しています。私はserver.port=8089
としてapplication.properties
ファイルにポートを設定していますspring-boot inbuilt tomcatサーバーが起動していません
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.7.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<!--<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</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-validation</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.restdocs</groupId>
<artifactId>spring-restdocs-mockmvc</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<!--<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
:
ポンポンは、次のようになります。私が行うとmvn clean package
すべてが正常に動作し、ビルドが成功である
@RequestMapping("/ping")
@RestController
public class helloController {
@RequestMapping(method= RequestMethod.GET,produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<String> ping(){
return new ResponseEntity<>("Hello World Spring-boot app", HttpStatus.OK);
}
:として1のPing URIは、コントローラクラスに追加があります。私はMain()
からアプリケーションを実行するときしかし、これは、ログは次のようになります。ログは、サービスが開始されたものをポート表示されていない
2017-09-19 10:37:32.219 INFO 6436 --- [ main] com.example.demo.DemoApplication : No active profile set, falling back to default profiles: default
2017-09-19 10:37:32.290 INFO 6436 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.spring[email protected]77f99a05: startup date [Tue Sep 19 10:37:32 PDT 2017]; root of context hierarchy
2017-09-19 10:37:33.782 INFO 6436 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2017-09-19 10:37:33.802 INFO 6436 --- [ main] com.example.demo.DemoApplication : Started DemoApplication in 2.043 seconds (JVM running for 2.802)
2017-09-19 10:37:33.802 INFO 6436 --- [ Thread-2] s.c.a.AnnotationConfigApplicationContext : Closing org.spring[email protected]77f99a05: startup date [Tue Sep 19 10:37:32 PDT 2017]; root of context hierarchy
2017-09-19 10:37:33.802 INFO 6436 --- [ Thread-2] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
。
指定されたポートでサービスを開始し、サーバーを稼動状態に保つために何を行う必要がありますか?
まず、spring-web依存関係を削除してください。コンパイラプラグインを削除し、 'spring-boot-maven-plugin'をre0-addしてください。また 'main'メソッドをどのように実行しますか?コマンドライン? IDE?または...? –
本当に関連していませんが、できるだけ早くあなたのコードからロンボクを取り除くことを教えてください。それはひどい考えです。 –
@ M.Deinum - あなたの提案によると、spring-boot-maven -pluginを再追加し、今回は** spring-boot:start **オプションでサーバを起動しました。ログにはアプリケーションがポート8089から始まっていますが、サーバーは再び停止します。 – worrynerd