Polish
This commit is contained in:
parent
93aefa8537
commit
e891aa3525
|
|
@ -81,14 +81,12 @@ import org.springframework.util.StringUtils;
|
|||
* into a Spring Boot enabled application. By default a SSH daemon is started on port
|
||||
* 2000. If the CRaSH Telnet plugin is available on the classpath, Telnet daemon will be
|
||||
* launched on port 5000.
|
||||
*
|
||||
* <p>
|
||||
* The default shell authentication method uses a username and password combination. If no
|
||||
* configuration is provided the default username is 'user' and the password will be
|
||||
* printed to console during application startup. Those default values can be overridden
|
||||
* by using <code>shell.auth.simple.username</code> and
|
||||
* <code>shell.auth.simple.password</code>.
|
||||
*
|
||||
* <p>
|
||||
* If a Spring Security {@link AuthenticationManager} is detected, this configuration will
|
||||
* create a {@link CRaSHPlugin} to forward shell authentication requests to Spring
|
||||
|
|
@ -98,14 +96,12 @@ import org.springframework.util.StringUtils;
|
|||
* restricted to users having roles that match those configured in
|
||||
* {@link ManagementServerProperties}. Required roles can be overridden by
|
||||
* <code>shell.auth.spring.roles</code>.
|
||||
*
|
||||
* <p>
|
||||
* To add customizations to the shell simply define beans of type {@link CRaSHPlugin} in
|
||||
* the application context. Those beans will get auto detected during startup and
|
||||
* registered with the underlying shell infrastructure. To configure plugins and the CRaSH
|
||||
* infrastructure add beans of type {@link CrshShellProperties} to the application
|
||||
* context.
|
||||
*
|
||||
* <p>
|
||||
* Additional shell commands can be implemented using the guide and documentation at <a
|
||||
* href="http://www.crashub.org">crashub.org</a>. By default Boot will search for commands
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public abstract class AutoConfigurationPackages {
|
|||
|
||||
/**
|
||||
* Determine if the auto-configuration base packages for the given bean factory are
|
||||
* available
|
||||
* available.
|
||||
* @param beanFactory the source bean factory
|
||||
* @return true if there are auto-config packages available
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
On * Copyright 2012-2014 the original author or authors.
|
||||
* Copyright 2012-2014 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.
|
||||
|
|
|
|||
|
|
@ -54,17 +54,19 @@ public class ElasticsearchAutoConfiguration implements DisposableBean {
|
|||
@Bean
|
||||
public Client elasticsearchClient() {
|
||||
try {
|
||||
if (StringUtils.hasLength(this.properties.getClusterNodes())) {
|
||||
this.client = createTransportClient();
|
||||
}
|
||||
else {
|
||||
this.client = createNodeClient();
|
||||
}
|
||||
this.client = createClient();
|
||||
return this.client;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
return this.client;
|
||||
}
|
||||
|
||||
private Client createClient() throws Exception {
|
||||
if (StringUtils.hasLength(this.properties.getClusterNodes())) {
|
||||
return createTransportClient();
|
||||
}
|
||||
return createNodeClient();
|
||||
}
|
||||
|
||||
private Client createNodeClient() throws Exception {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
* Copyright 2012-2014 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.
|
||||
|
|
@ -32,7 +32,7 @@ import org.springframework.integration.jmx.config.IntegrationMBeanExportConfigur
|
|||
*
|
||||
* @author Artem Bilan
|
||||
* @author Dave Syer
|
||||
* @since 1.1
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnClass(EnableIntegration.class)
|
||||
|
|
|
|||
|
|
@ -65,33 +65,29 @@ public class JacksonAutoConfiguration {
|
|||
private ListableBeanFactory beanFactory;
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@Primary
|
||||
@ConditionalOnMissingBean
|
||||
public ObjectMapper jacksonObjectMapper() {
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
if (this.properties.isJsonSortKeys()) {
|
||||
objectMapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);
|
||||
}
|
||||
|
||||
return objectMapper;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
|
||||
Collection<ObjectMapper> mappers = BeanFactoryUtils
|
||||
.beansOfTypeIncludingAncestors(this.beanFactory, ObjectMapper.class)
|
||||
.values();
|
||||
Collection<Module> modules = BeanFactoryUtils.beansOfTypeIncludingAncestors(
|
||||
this.beanFactory, Module.class).values();
|
||||
|
||||
for (ObjectMapper mapper : mappers) {
|
||||
mapper.registerModules(modules);
|
||||
private void registerModulesWithObjectMappers() {
|
||||
Collection<Module> modules = getBeans(Module.class);
|
||||
for (ObjectMapper objectMapper : getBeans(ObjectMapper.class)) {
|
||||
objectMapper.registerModules(modules);
|
||||
}
|
||||
}
|
||||
|
||||
private <T> Collection<T> getBeans(Class<T> type) {
|
||||
return BeanFactoryUtils.beansOfTypeIncludingAncestors(this.beanFactory, type)
|
||||
.values();
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnClass(JodaModule.class)
|
||||
static class JodaModuleAutoConfiguration {
|
||||
|
|
@ -101,6 +97,7 @@ public class JacksonAutoConfiguration {
|
|||
JodaModule jacksonJodaModule() {
|
||||
return new JodaModule();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
|
@ -113,5 +110,6 @@ public class JacksonAutoConfiguration {
|
|||
JSR310Module jacksonJsr310Module() {
|
||||
return new JSR310Module();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,9 +53,9 @@ import org.springframework.util.ClassUtils;
|
|||
|
||||
/**
|
||||
* {@link org.springframework.boot.autoconfigure.EnableAutoConfiguration
|
||||
* Auto-configuration} to integrate with an HornetQ broker. If the necessary
|
||||
* classes are present, embed the broker in the application by default. Otherwise,
|
||||
* connect to a broker available on the local machine with the default settings.
|
||||
* Auto-configuration} to integrate with an HornetQ broker. If the necessary classes are
|
||||
* present, embed the broker in the application by default. Otherwise, connect to a broker
|
||||
* available on the local machine with the default settings.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @since 1.1.0
|
||||
|
|
|
|||
|
|
@ -58,6 +58,8 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
|
|||
@Import(DataSourceInitializedPublisher.Registrar.class)
|
||||
public abstract class JpaBaseConfiguration implements BeanFactoryAware {
|
||||
|
||||
private static final String[] NO_PACKAGES = new String[0];
|
||||
|
||||
private ConfigurableListableBeanFactory beanFactory;
|
||||
|
||||
@Autowired
|
||||
|
|
@ -118,7 +120,7 @@ public abstract class JpaBaseConfiguration implements BeanFactoryAware {
|
|||
List<String> basePackages = AutoConfigurationPackages.get(this.beanFactory);
|
||||
return basePackages.toArray(new String[basePackages.size()]);
|
||||
}
|
||||
return new String[0];
|
||||
return NO_PACKAGES;
|
||||
}
|
||||
|
||||
protected void configure(
|
||||
|
|
|
|||
|
|
@ -75,5 +75,7 @@ public class HttpMessageConvertersAutoConfiguration {
|
|||
converter.setPrettyPrint(this.properties.isJsonPrettyPrint());
|
||||
return converter;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@
|
|||
|
||||
package org.springframework.boot.autoconfigure.batch;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.Job;
|
||||
|
|
@ -46,6 +44,8 @@ import org.springframework.context.annotation.Configuration;
|
|||
import org.springframework.core.task.SyncTaskExecutor;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Tests for {@link JobLauncherCommandLineRunner}.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,9 +17,8 @@
|
|||
package org.springframework.boot.autoconfigure.jackson;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.joda.time.LocalDateTime;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
|
@ -40,6 +39,7 @@ import com.fasterxml.jackson.databind.SerializerProvider;
|
|||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
import com.fasterxml.jackson.datatype.joda.JodaModule;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
import static org.hamcrest.Matchers.hasItem;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
|
@ -72,27 +72,20 @@ public class JacksonAutoConfigurationTests {
|
|||
|
||||
@Test
|
||||
public void registersJodaModuleAutomatically() {
|
||||
|
||||
this.context.register(JacksonAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
|
||||
Collection<Module> modules = this.context.getBeansOfType(Module.class).values();
|
||||
assertThat(modules, is(Matchers.<Module> iterableWithSize(1)));
|
||||
assertThat(modules.iterator().next(), is(instanceOf(JodaModule.class)));
|
||||
|
||||
Map<String, Module> modules = this.context.getBeansOfType(Module.class);
|
||||
assertThat(modules.size(), greaterThanOrEqualTo(1)); // Depends on the JDK
|
||||
assertThat(modules.get("jacksonJodaModule"), is(instanceOf(JodaModule.class)));
|
||||
ObjectMapper objectMapper = this.context.getBean(ObjectMapper.class);
|
||||
assertThat(objectMapper.canSerialize(LocalDateTime.class), is(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customJacksonModules() throws Exception {
|
||||
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
this.context.register(ModulesConfig.class, JacksonAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
|
||||
ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
|
||||
|
||||
@SuppressWarnings({ "unchecked", "unused" })
|
||||
ObjectMapper result = verify(mapper).registerModules(
|
||||
(Iterable<Module>) argThat(hasItem(this.context.getBean("jacksonModule",
|
||||
|
|
@ -101,12 +94,9 @@ public class JacksonAutoConfigurationTests {
|
|||
|
||||
@Test
|
||||
public void doubleModuleRegistration() throws Exception {
|
||||
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
this.context.register(DoubleModulesConfig.class,
|
||||
HttpMessageConvertersAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
|
||||
ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
|
||||
assertEquals("{\"foo\":\"bar\"}", mapper.writeValueAsString(new Foo()));
|
||||
}
|
||||
|
|
@ -124,6 +114,7 @@ public class JacksonAutoConfigurationTests {
|
|||
public ObjectMapper objectMapper() {
|
||||
return Mockito.mock(ObjectMapper.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
|
@ -153,6 +144,7 @@ public class JacksonAutoConfigurationTests {
|
|||
mapper.registerModule(jacksonModule());
|
||||
return mapper;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected static class Foo {
|
||||
|
|
@ -160,7 +152,6 @@ public class JacksonAutoConfigurationTests {
|
|||
private String name;
|
||||
|
||||
private Foo() {
|
||||
|
||||
}
|
||||
|
||||
static Foo create() {
|
||||
|
|
@ -176,4 +167,5 @@ public class JacksonAutoConfigurationTests {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,11 +16,6 @@
|
|||
|
||||
package org.springframework.boot.autoconfigure.orm.jpa;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.After;
|
||||
|
|
@ -34,6 +29,10 @@ import org.springframework.boot.test.EnvironmentTestUtils;
|
|||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link HibernateJpaAutoConfiguration}.
|
||||
*
|
||||
|
|
@ -66,7 +65,7 @@ public class CustomHibernateJpaAutoConfigurationTests {
|
|||
String actual = bean.getHibernateProperties(dataSource).get(
|
||||
"hibernate.hbm2ddl.auto");
|
||||
// Default is generic and safe
|
||||
assertThat(actual, is(nullValue()));
|
||||
assertThat(actual, nullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* Copyright 2012-2014 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.
|
||||
|
|
@ -16,8 +16,6 @@
|
|||
|
||||
package org.springframework.boot.autoconfigure.reactor;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
|
@ -27,7 +25,11 @@ import reactor.core.Environment;
|
|||
import reactor.core.Reactor;
|
||||
import reactor.core.spec.Reactors;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* Tests for {@link ReactorAutoConfiguration}.
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class ReactorAutoConfigurationTests {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,32 @@
|
|||
/*
|
||||
* Copyright 2012-2014 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.security.jpa;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.security.user.SecurityConfig;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
|
|
@ -13,11 +36,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|||
* their instantiation order was accelerated by Security).
|
||||
*
|
||||
* @author Dave Syer
|
||||
*
|
||||
* @since 1.1
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringApplicationConfiguration(classes = Main.class)
|
||||
@SpringApplicationConfiguration(classes = JpaUserDetailsTests.Main.class)
|
||||
public class JpaUserDetailsTests {
|
||||
|
||||
@Test
|
||||
|
|
@ -28,4 +49,10 @@ public class JpaUserDetailsTests {
|
|||
SpringApplication.run(Main.class, args);
|
||||
}
|
||||
|
||||
@Import({ DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class, SecurityAutoConfiguration.class })
|
||||
@ComponentScan(basePackageClasses = SecurityConfig.class)
|
||||
public static class Main {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012-2013 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.security.jpa;
|
||||
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.security.user.SecurityConfig;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
@Import({ DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class, SecurityAutoConfiguration.class })
|
||||
@ComponentScan(basePackageClasses = SecurityConfig.class)
|
||||
public class Main {
|
||||
}
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package org.springframework.boot.autoconfigure.security.user;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2012-2014 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.security.user;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
|
@ -6,9 +22,11 @@ import javax.persistence.Id;
|
|||
|
||||
@Entity
|
||||
public class User {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
private String email;
|
||||
|
||||
public User() {
|
||||
|
|
@ -19,7 +37,7 @@ public class User {
|
|||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
|
|
@ -27,14 +45,16 @@ public class User {
|
|||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
return this.email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getSimpleName() + ":" + id;
|
||||
return getClass().getSimpleName() + ":" + this.id;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,25 @@
|
|||
/*
|
||||
* Copyright 2012-2014 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.security.user;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface UserRepository extends JpaRepository<User, Integer> {
|
||||
|
||||
public User findByEmail(String email);
|
||||
|
||||
}
|
||||
|
|
@ -36,7 +36,7 @@ import static org.junit.Assert.assertTrue;
|
|||
*/
|
||||
public class HttpMessageConvertersAutoConfigurationTests {
|
||||
|
||||
private AnnotationConfigApplicationContext context;
|
||||
private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();;
|
||||
|
||||
@After
|
||||
public void close() {
|
||||
|
|
@ -47,17 +47,13 @@ public class HttpMessageConvertersAutoConfigurationTests {
|
|||
|
||||
@Test
|
||||
public void customJacksonConverter() throws Exception {
|
||||
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
this.context.register(JacksonConfig.class,
|
||||
HttpMessageConvertersAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
|
||||
MappingJackson2HttpMessageConverter converter = this.context
|
||||
.getBean(MappingJackson2HttpMessageConverter.class);
|
||||
assertEquals(this.context.getBean(ObjectMapper.class),
|
||||
converter.getObjectMapper());
|
||||
|
||||
HttpMessageConverters converters = this.context
|
||||
.getBean(HttpMessageConverters.class);
|
||||
assertTrue(converters.getConverters().contains(converter));
|
||||
|
|
@ -77,5 +73,7 @@ public class HttpMessageConvertersAutoConfigurationTests {
|
|||
public ObjectMapper objectMapper() {
|
||||
return new ObjectMapper();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -319,7 +319,7 @@ public class WebMvcAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Configuration
|
||||
protected static class Config {
|
||||
public static class Config {
|
||||
|
||||
@Bean
|
||||
public EmbeddedServletContainerFactory containerFactory() {
|
||||
|
|
|
|||
|
|
@ -33,4 +33,3 @@ databaseChangeLog:
|
|||
type: varchar(50)
|
||||
constraints:
|
||||
nullable: true
|
||||
|
||||
|
|
@ -9,4 +9,5 @@ class Sample implements CommandLineRunner {
|
|||
void run(String... args) {
|
||||
println "Hello World"
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -21,7 +21,6 @@ import org.gradle.api.Project
|
|||
import org.gradle.api.plugins.ApplicationPlugin
|
||||
import org.gradle.api.plugins.BasePlugin
|
||||
import org.gradle.api.plugins.JavaPlugin
|
||||
import org.gradle.api.tasks.compile.Compile
|
||||
import org.springframework.boot.gradle.agent.AgentPluginFeatures
|
||||
import org.springframework.boot.gradle.repackage.RepackagePluginFeatures
|
||||
import org.springframework.boot.gradle.resolve.ResolvePluginFeatures
|
||||
|
|
@ -48,11 +47,14 @@ class SpringBootPlugin implements Plugin<Project> {
|
|||
new RepackagePluginFeatures().apply(project)
|
||||
new RunPluginFeatures().apply(project)
|
||||
|
||||
// default to UTF-8 encoding
|
||||
project.tasks.withType(Compile).all { t->
|
||||
t.doFirst {
|
||||
if(!t.options.encoding) {
|
||||
t.options.encoding = 'UTF-8'
|
||||
useUtf8Encoding(project)
|
||||
}
|
||||
|
||||
private useUtf8Encoding(Project project) {
|
||||
project.tasks.withType(org.gradle.api.tasks.compile.Compile).all {
|
||||
it.doFirst {
|
||||
if(!it.options.encoding) {
|
||||
it.options.encoding = 'UTF-8'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -383,10 +383,6 @@ public class ConfigurationPropertiesBindingPostProcessor implements BeanPostProc
|
|||
/**
|
||||
* Convenience class to flatten out a tree of property sources without losing the
|
||||
* reference to the backing data (which can therefore be updated in the background).
|
||||
*
|
||||
* @param propertySources some PropertySources, possibly containing environment
|
||||
* properties
|
||||
* @return another PropertySources containing the same properties
|
||||
*/
|
||||
private static class FlatPropertySources implements PropertySources {
|
||||
|
||||
|
|
@ -414,7 +410,7 @@ public class ConfigurationPropertiesBindingPostProcessor implements BeanPostProc
|
|||
|
||||
private MutablePropertySources getFlattened() {
|
||||
MutablePropertySources result = new MutablePropertySources();
|
||||
for (PropertySource<?> propertySource : propertySources) {
|
||||
for (PropertySource<?> propertySource : this.propertySources) {
|
||||
flattenPropertySources(propertySource, result);
|
||||
}
|
||||
return result;
|
||||
|
|
|
|||
Loading…
Reference in New Issue