org.springframework.boot.autoconfigure.h2.plus.H2ServerAutoConfiguration Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of h2-plus Show documentation
Show all versions of h2-plus Show documentation
Extended implementation of H2
The newest version!
/*
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.h2.plus;
import org.h2.plus.H2Server;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* {@link H2Server} auto configuration
*/
@Configuration
@ConditionalOnProperty(prefix = H2ServerProperties.PREFIX, name = "enabled", havingValue = "true")
@EnableConfigurationProperties(H2ServerProperties.class)
public class H2ServerAutoConfiguration {
/**
* {@link H2ServerProperties}
*/
@Autowired
private H2ServerProperties properties;
/**
* {@link H2Server}
*
* @return {@link H2Server}
*/
@Bean(initMethod = "start", destroyMethod = "stop")
public H2Server h2Server() {
return H2Server.builder()
/* @formatter:off */
.port(this.properties.getPort())
.baseDir(this.properties.getBaseDir())
.allowOthers(this.properties.isAllowOthers())
.daemon(this.properties.isDaemon())
/* @formatter:on */
.build();
}
}