Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
02cc7789
Commit
02cc7789
authored
Apr 23, 2021
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract code samples from docs
See gh-6313
parent
3075ac0f
Changes
38
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
38 changed files
with
1313 additions
and
397 deletions
+1313
-397
build.gradle
spring-boot-project/spring-boot-docs/build.gradle
+11
-0
spring-boot-features.adoc
...ing-boot-docs/src/docs/asciidoc/spring-boot-features.adoc
+62
-395
CustomEntityManagerFactoryExample.java
...s/howto/dataaccess/CustomEntityManagerFactoryExample.java
+1
-1
CacheManagerCustomizerConfiguration.java
...features/caching/CacheManagerCustomizerConfiguration.java
+32
-0
MathService.java
...ork/boot/docs/springbootfeatures/caching/MathService.java
+30
-0
AcmeProperties.java
.../externalizedconfiguration/merge/list/AcmeProperties.java
+1
-1
MyBean.java
...s/springbootfeatures/messaging/amqp/receiving/MyBean.java
+30
-0
MyBean.java
...gbootfeatures/messaging/amqp/receiving/custom/MyBean.java
+30
-0
RabbitConfiguration.java
.../messaging/amqp/receiving/custom/RabbitConfiguration.java
+60
-0
MyBean.java
...ocs/springbootfeatures/messaging/amqp/sending/MyBean.java
+45
-0
MyBean.java
...cs/springbootfeatures/messaging/jms/receiving/MyBean.java
+30
-0
JmsConfiguration.java
...ures/messaging/jms/receiving/custom/JmsConfiguration.java
+62
-0
MyBean.java
...ngbootfeatures/messaging/jms/receiving/custom/MyBean.java
+30
-0
MyBean.java
...ocs/springbootfeatures/messaging/jms/template/MyBean.java
+37
-0
MyBean.java
.../springbootfeatures/messaging/kafka/receiving/MyBean.java
+30
-0
MyBean.java
...cs/springbootfeatures/messaging/kafka/sending/MyBean.java
+39
-0
MyTest.java
...gbootfeatures/messaging/kafka/test/annotation/MyTest.java
+28
-0
MyTest.java
...ingbootfeatures/messaging/kafka/test/property/MyTest.java
+31
-0
MyBean.java
...s/springbootfeatures/nosql/cassandra/template/MyBean.java
+42
-0
CouchbaseConversionsConfiguration.java
...es/nosql/couchbase/CouchbaseConversionsConfiguration.java
+49
-0
MyBean.java
...s/springbootfeatures/nosql/couchbase/template/MyBean.java
+37
-0
MyBean.java
...ringbootfeatures/nosql/elasticsearch/template/MyBean.java
+42
-0
MyBean.java
...t/docs/springbootfeatures/nosql/ldap/template/MyBean.java
+44
-0
City.java
...boot/docs/springbootfeatures/nosql/mongodb/data/City.java
+21
-0
CityRepository.java
...springbootfeatures/nosql/mongodb/data/CityRepository.java
+29
-0
MyBean.java
...ingbootfeatures/nosql/mongodb/databasefactory/MyBean.java
+42
-0
MyBean.java
...ocs/springbootfeatures/nosql/mongodb/template/MyBean.java
+40
-0
City.java
...k/boot/docs/springbootfeatures/nosql/neo4j/data/City.java
+21
-0
CityRepository.java
...s/springbootfeatures/nosql/neo4j/data/CityRepository.java
+27
-0
MyBean.java
...ot/docs/springbootfeatures/nosql/neo4j/driver/MyBean.java
+45
-0
MyBean.java
...work/boot/docs/springbootfeatures/nosql/redis/MyBean.java
+37
-0
MyBean.java
...oot/docs/springbootfeatures/nosql/solr/client/MyBean.java
+42
-0
MyService.java
.../boot/docs/springbootfeatures/resttemplate/MyService.java
+41
-0
City.java
...ramework/boot/docs/springbootfeatures/sql/r2dbc/City.java
+21
-0
CityRepository.java
...oot/docs/springbootfeatures/sql/r2dbc/CityRepository.java
+27
-0
CustomizeR2dbcPortConfiguration.java
...otfeatures/sql/r2dbc/CustomizeR2dbcPortConfiguration.java
+35
-0
CustomizeR2dbcPostgresOptionsConfiguration.java
...sql/r2dbc/CustomizeR2dbcPostgresOptionsConfiguration.java
+41
-0
MyBean.java
...s/springbootfeatures/sql/r2dbc/databaseclient/MyBean.java
+41
-0
No files found.
spring-boot-project/spring-boot-docs/build.gradle
View file @
02cc7789
...
...
@@ -69,12 +69,15 @@ dependencies {
implementation
(
"com.zaxxer:HikariCP"
)
implementation
(
"io.micrometer:micrometer-core"
)
implementation
(
"io.projectreactor.netty:reactor-netty-http"
)
implementation
(
"io.r2dbc:r2dbc-postgresql"
)
implementation
(
"io.undertow:undertow-core"
)
implementation
(
"jakarta.annotation:jakarta.annotation-api"
)
implementation
(
"jakarta.jms:jakarta.jms-api"
)
implementation
(
"jakarta.servlet:jakarta.servlet-api"
)
implementation
(
"org.apache.commons:commons-dbcp2"
)
implementation
(
"org.apache.kafka:kafka-streams"
)
implementation
(
"org.apache.logging.log4j:log4j-to-slf4j"
)
implementation
(
"org.apache.solr:solr-solrj"
)
implementation
(
"org.apache.tomcat.embed:tomcat-embed-core"
)
implementation
(
"org.assertj:assertj-core"
)
implementation
(
"org.glassfish.jersey.core:jersey-server"
)
...
...
@@ -83,16 +86,24 @@ dependencies {
implementation
(
"org.mongodb:mongodb-driver-sync"
)
implementation
(
"org.slf4j:jul-to-slf4j"
)
implementation
(
"org.springframework:spring-jdbc"
)
implementation
(
"org.springframework:spring-jms"
)
implementation
(
"org.springframework:spring-orm"
)
implementation
(
"org.springframework:spring-test"
)
implementation
(
"org.springframework:spring-web"
)
implementation
(
"org.springframework:spring-webmvc"
)
implementation
(
"org.springframework:spring-webflux"
)
implementation
(
"org.springframework.amqp:spring-amqp"
)
implementation
(
"org.springframework.amqp:spring-rabbit"
)
implementation
(
"org.springframework.data:spring-data-cassandra"
)
implementation
(
"org.springframework.data:spring-data-couchbase"
)
implementation
(
"org.springframework.data:spring-data-elasticsearch"
)
implementation
(
"org.springframework.data:spring-data-ldap"
)
implementation
(
"org.springframework.data:spring-data-mongodb"
)
implementation
(
"org.springframework.data:spring-data-neo4j"
)
implementation
(
"org.springframework.data:spring-data-redis"
)
implementation
(
"org.springframework.data:spring-data-r2dbc"
)
implementation
(
"org.springframework.kafka:spring-kafka"
)
implementation
(
"org.springframework.kafka:spring-kafka-test"
)
implementation
(
"org.springframework.restdocs:spring-restdocs-restassured"
)
implementation
(
"org.springframework.restdocs:spring-restdocs-webtestclient"
)
implementation
(
"org.springframework.security:spring-security-config"
)
...
...
spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc
View file @
02cc7789
This diff is collapsed.
Click to expand it.
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/CustomEntityManagerFactoryExample.java
View file @
02cc7789
...
...
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
docs
.
jpa
;
package
org
.
springframework
.
boot
.
docs
.
howto
.
dataaccess
;
import
javax.sql.DataSource
;
...
...
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/caching/CacheManagerCustomizerConfiguration.java
0 → 100644
View file @
02cc7789
/*
* Copyright 2012-2021 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
*
* https://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
.
docs
.
springbootfeatures
.
caching
;
import
org.springframework.boot.autoconfigure.cache.CacheManagerCustomizer
;
import
org.springframework.cache.concurrent.ConcurrentMapCacheManager
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
@Configuration
public
class
CacheManagerCustomizerConfiguration
{
@Bean
public
CacheManagerCustomizer
<
ConcurrentMapCacheManager
>
cacheManagerCustomizer
()
{
return
(
cacheManager
)
->
cacheManager
.
setAllowNullValues
(
false
);
}
}
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/caching/MathService.java
0 → 100644
View file @
02cc7789
/*
* Copyright 2012-2021 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
*
* https://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
.
docs
.
springbootfeatures
.
caching
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.stereotype.Component
;
@Component
public
class
MathService
{
@Cacheable
(
"piDecimals"
)
public
int
computePiDecimal
(
int
precision
)
{
/**/
return
0
;
}
}
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/merge/list/AcmeProperties.java
View file @
02cc7789
...
...
@@ -31,7 +31,7 @@ public class AcmeProperties {
}
}
// @chomp:
file
// @chomp:file
class
MyPojo
{
...
...
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/messaging/amqp/receiving/MyBean.java
0 → 100644
View file @
02cc7789
/*
* Copyright 2012-2021 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
*
* https://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
.
docs
.
springbootfeatures
.
messaging
.
amqp
.
receiving
;
import
org.springframework.amqp.rabbit.annotation.RabbitListener
;
import
org.springframework.stereotype.Component
;
@Component
public
class
MyBean
{
@RabbitListener
(
queues
=
"someQueue"
)
public
void
processMessage
(
String
content
)
{
// ...
}
}
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/messaging/amqp/receiving/custom/MyBean.java
0 → 100644
View file @
02cc7789
/*
* Copyright 2012-2021 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
*
* https://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
.
docs
.
springbootfeatures
.
messaging
.
amqp
.
receiving
.
custom
;
import
org.springframework.amqp.rabbit.annotation.RabbitListener
;
import
org.springframework.stereotype.Component
;
@Component
public
class
MyBean
{
@RabbitListener
(
queues
=
"someQueue"
,
containerFactory
=
"myFactory"
)
public
void
processMessage
(
String
content
)
{
// ...
}
}
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/messaging/amqp/receiving/custom/RabbitConfiguration.java
0 → 100644
View file @
02cc7789
/*
* Copyright 2012-2021 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
*
* https://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
.
docs
.
springbootfeatures
.
messaging
.
amqp
.
receiving
.
custom
;
import
org.springframework.amqp.core.Message
;
import
org.springframework.amqp.core.MessageProperties
;
import
org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory
;
import
org.springframework.amqp.rabbit.connection.ConnectionFactory
;
import
org.springframework.amqp.support.converter.MessageConversionException
;
import
org.springframework.amqp.support.converter.MessageConverter
;
import
org.springframework.boot.autoconfigure.amqp.SimpleRabbitListenerContainerFactoryConfigurer
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
@Configuration
(
proxyBeanMethods
=
false
)
public
class
RabbitConfiguration
{
@Bean
public
SimpleRabbitListenerContainerFactory
myFactory
(
SimpleRabbitListenerContainerFactoryConfigurer
configurer
)
{
SimpleRabbitListenerContainerFactory
factory
=
new
SimpleRabbitListenerContainerFactory
();
ConnectionFactory
connectionFactory
=
getCustomConnectionFactory
();
configurer
.
configure
(
factory
,
connectionFactory
);
factory
.
setMessageConverter
(
new
MyMessageConverter
());
return
factory
;
}
private
ConnectionFactory
getCustomConnectionFactory
()
{
return
/**/
null
;
}
}
// @chomp:file
class
MyMessageConverter
implements
MessageConverter
{
@Override
public
Message
toMessage
(
Object
object
,
MessageProperties
messageProperties
)
throws
MessageConversionException
{
return
null
;
}
@Override
public
Object
fromMessage
(
Message
message
)
throws
MessageConversionException
{
return
null
;
}
}
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/messaging/amqp/sending/MyBean.java
0 → 100644
View file @
02cc7789
/*
* Copyright 2012-2021 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
*
* https://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
.
docs
.
springbootfeatures
.
messaging
.
amqp
.
sending
;
import
org.springframework.amqp.core.AmqpAdmin
;
import
org.springframework.amqp.core.AmqpTemplate
;
import
org.springframework.stereotype.Component
;
@Component
public
class
MyBean
{
private
final
AmqpAdmin
amqpAdmin
;
private
final
AmqpTemplate
amqpTemplate
;
public
MyBean
(
AmqpAdmin
amqpAdmin
,
AmqpTemplate
amqpTemplate
)
{
this
.
amqpAdmin
=
amqpAdmin
;
this
.
amqpTemplate
=
amqpTemplate
;
}
// @fold:on
public
void
someMethod
()
{
this
.
amqpAdmin
.
getQueueInfo
(
"someQueue"
);
}
public
void
someOtherMethod
()
{
this
.
amqpTemplate
.
convertAndSend
(
"hello"
);
}
// @fold:off
}
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/messaging/jms/receiving/MyBean.java
0 → 100644
View file @
02cc7789
/*
* Copyright 2012-2021 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
*
* https://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
.
docs
.
springbootfeatures
.
messaging
.
jms
.
receiving
;
import
org.springframework.jms.annotation.JmsListener
;
import
org.springframework.stereotype.Component
;
@Component
public
class
MyBean
{
@JmsListener
(
destination
=
"someQueue"
)
public
void
processMessage
(
String
content
)
{
// ...
}
}
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/messaging/jms/receiving/custom/JmsConfiguration.java
0 → 100644
View file @
02cc7789
/*
* Copyright 2012-2021 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
*
* https://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
.
docs
.
springbootfeatures
.
messaging
.
jms
.
receiving
.
custom
;
import
javax.jms.ConnectionFactory
;
import
javax.jms.JMSException
;
import
javax.jms.Message
;
import
javax.jms.Session
;
import
org.springframework.boot.autoconfigure.jms.DefaultJmsListenerContainerFactoryConfigurer
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.jms.config.DefaultJmsListenerContainerFactory
;
import
org.springframework.jms.support.converter.MessageConversionException
;
import
org.springframework.jms.support.converter.MessageConverter
;
@Configuration
(
proxyBeanMethods
=
false
)
public
class
JmsConfiguration
{
@Bean
public
DefaultJmsListenerContainerFactory
myFactory
(
DefaultJmsListenerContainerFactoryConfigurer
configurer
)
{
DefaultJmsListenerContainerFactory
factory
=
new
DefaultJmsListenerContainerFactory
();
ConnectionFactory
connectionFactory
=
getCustomConnectionFactory
();
configurer
.
configure
(
factory
,
connectionFactory
);
factory
.
setMessageConverter
(
new
MyMessageConverter
());
return
factory
;
}
private
ConnectionFactory
getCustomConnectionFactory
()
{
return
/**/
null
;
}
}
// @chomp:file
class
MyMessageConverter
implements
MessageConverter
{
@Override
public
Message
toMessage
(
Object
object
,
Session
session
)
throws
JMSException
,
MessageConversionException
{
return
null
;
}
@Override
public
Object
fromMessage
(
Message
message
)
throws
JMSException
,
MessageConversionException
{
return
null
;
}
}
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/messaging/jms/receiving/custom/MyBean.java
0 → 100644
View file @
02cc7789
/*
* Copyright 2012-2021 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
*
* https://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
.
docs
.
springbootfeatures
.
messaging
.
jms
.
receiving
.
custom
;
import
org.springframework.jms.annotation.JmsListener
;
import
org.springframework.stereotype.Component
;
@Component
public
class
MyBean
{
@JmsListener
(
destination
=
"someQueue"
,
containerFactory
=
"myFactory"
)
public
void
processMessage
(
String
content
)
{
// ...
}
}
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/messaging/jms/template/MyBean.java
0 → 100644
View file @
02cc7789
/*
* Copyright 2012-2021 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
*
* https://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
.
docs
.
springbootfeatures
.
messaging
.
jms
.
template
;
import
org.springframework.jms.core.JmsTemplate
;
import
org.springframework.stereotype.Component
;
@Component
public
class
MyBean
{
private
final
JmsTemplate
jmsTemplate
;
public
MyBean
(
JmsTemplate
jmsTemplate
)
{
this
.
jmsTemplate
=
jmsTemplate
;
}
// @fold:on // ...
public
void
someMethod
()
{
this
.
jmsTemplate
.
convertAndSend
(
"hello"
);
}
// @fold:off
}
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/messaging/kafka/receiving/MyBean.java
0 → 100644
View file @
02cc7789
/*
* Copyright 2012-2021 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
*
* https://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
.
docs
.
springbootfeatures
.
messaging
.
kafka
.
receiving
;
import
org.springframework.kafka.annotation.KafkaListener
;
import
org.springframework.stereotype.Component
;
@Component
public
class
MyBean
{
@KafkaListener
(
topics
=
"someTopic"
)
public
void
processMessage
(
String
content
)
{
// ...
}
}
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/messaging/kafka/sending/MyBean.java
0 → 100644
View file @
02cc7789
/*
* Copyright 2012-2021 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
*
* https://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
.
docs
.
springbootfeatures
.
messaging
.
kafka
.
sending
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.kafka.core.KafkaTemplate
;
import
org.springframework.stereotype.Component
;
@Component
public
class
MyBean
{
private
final
KafkaTemplate
<
String
,
String
>
kafkaTemplate
;
@Autowired
public
MyBean
(
KafkaTemplate
<
String
,
String
>
kafkaTemplate
)
{
this
.
kafkaTemplate
=
kafkaTemplate
;
}
// @fold:on // ...
public
void
someMethod
()
{
this
.
kafkaTemplate
.
send
(
"someTopic"
,
"Hello"
);
}
// @fold:off
}
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/messaging/kafka/test/annotation/MyTest.java
0 → 100644
View file @
02cc7789
/*
* Copyright 2012-2021 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
*
* https://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
.
docs
.
springbootfeatures
.
messaging
.
kafka
.
test
.
annotation
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.kafka.test.context.EmbeddedKafka
;
@SpringBootTest
@EmbeddedKafka
(
topics
=
"someTopic"
,
bootstrapServersProperty
=
"spring.kafka.bootstrap-servers"
)
public
class
MyTest
{
// ...
}
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/messaging/kafka/test/property/MyTest.java
0 → 100644
View file @
02cc7789
/*
* Copyright 2012-2021 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
*
* https://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
.
docs
.
springbootfeatures
.
messaging
.
kafka
.
test
.
property
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.kafka.test.EmbeddedKafkaBroker
;
@SpringBootTest
public
class
MyTest
{
// tag::code[]
static
{
System
.
setProperty
(
EmbeddedKafkaBroker
.
BROKER_LIST_PROPERTY
,
"spring.kafka.bootstrap-servers"
);
}
// end::code[]
}
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/cassandra/template/MyBean.java
0 → 100644
View file @
02cc7789
/*
* Copyright 2012-2021 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
*
* https://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
.
docs
.
springbootfeatures
.
nosql
.
cassandra
.
template
;
import
org.springframework.data.cassandra.core.CassandraTemplate
;
import
org.springframework.stereotype.Component
;
@Component
public
class
MyBean
{
private
final
CassandraTemplate
template
;
public
MyBean
(
CassandraTemplate
template
)
{
this
.
template
=
template
;
}
// @fold:on // ...
public
long
someMethod
()
{
return
this
.
template
.
count
(
User
.
class
);
}
// @fold:off
}
// @chomp:file
class
User
{
}
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/couchbase/CouchbaseConversionsConfiguration.java
0 → 100644
View file @
02cc7789
/*
* Copyright 2012-2021 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
*
* https://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
.
docs
.
springbootfeatures
.
nosql
.
couchbase
;
import
org.assertj.core.util.Arrays
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.convert.converter.Converter
;
import
org.springframework.data.couchbase.config.BeanNames
;
import
org.springframework.data.couchbase.core.convert.CouchbaseCustomConversions
;
@Configuration
(
proxyBeanMethods
=
false
)
public
class
CouchbaseConversionsConfiguration
{
@Bean
(
BeanNames
.
COUCHBASE_CUSTOM_CONVERSIONS
)
public
CouchbaseCustomConversions
myCustomConversions
()
{
return
new
CouchbaseCustomConversions
(
Arrays
.
asList
(
new
MyConverter
()));
}
}
// @chomp:file
class
CouchbaseProperties
{
}
class
MyConverter
implements
Converter
<
CouchbaseProperties
,
Boolean
>
{
@Override
public
Boolean
convert
(
CouchbaseProperties
value
)
{
return
true
;
}
}
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/couchbase/template/MyBean.java
0 → 100644
View file @
02cc7789
/*
* Copyright 2012-2021 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
*
* https://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
.
docs
.
springbootfeatures
.
nosql
.
couchbase
.
template
;
import
org.springframework.data.couchbase.core.CouchbaseTemplate
;
import
org.springframework.stereotype.Component
;
@Component
public
class
MyBean
{
private
final
CouchbaseTemplate
template
;
public
MyBean
(
CouchbaseTemplate
template
)
{
this
.
template
=
template
;
}
// @fold:on // ...
public
String
someMethod
()
{
return
this
.
template
.
getBucketName
();
}
// @fold:off
}
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/elasticsearch/template/MyBean.java
0 → 100644
View file @
02cc7789
/*
* Copyright 2012-2021 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
*
* https://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
.
docs
.
springbootfeatures
.
nosql
.
elasticsearch
.
template
;
import
org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate
;
import
org.springframework.stereotype.Component
;
@Component
public
class
MyBean
{
private
final
ElasticsearchRestTemplate
template
;
public
MyBean
(
ElasticsearchRestTemplate
template
)
{
this
.
template
=
template
;
}
// @fold:on // ...
public
boolean
someMethod
(
String
id
)
{
return
this
.
template
.
exists
(
id
,
User
.
class
);
}
// @fold:off
}
// @chomp:file
class
User
{
}
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/ldap/template/MyBean.java
0 → 100644
View file @
02cc7789
/*
* Copyright 2012-2021 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
*
* https://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
.
docs
.
springbootfeatures
.
nosql
.
ldap
.
template
;
import
java.util.List
;
import
org.springframework.ldap.core.LdapTemplate
;
import
org.springframework.stereotype.Component
;
@Component
public
class
MyBean
{
private
final
LdapTemplate
template
;
public
MyBean
(
LdapTemplate
template
)
{
this
.
template
=
template
;
}
// @fold:on // ...
public
List
<
User
>
someMethod
()
{
return
this
.
template
.
findAll
(
User
.
class
);
}
// @fold:off
}
// @chomp:file
class
User
{
}
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/mongodb/data/City.java
0 → 100644
View file @
02cc7789
/*
* Copyright 2012-2021 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
*
* https://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
.
docs
.
springbootfeatures
.
nosql
.
mongodb
.
data
;
public
class
City
{
}
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/mongodb/data/CityRepository.java
0 → 100644
View file @
02cc7789
/*
* Copyright 2012-2021 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
*
* https://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
.
docs
.
springbootfeatures
.
nosql
.
mongodb
.
data
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.repository.Repository
;
public
interface
CityRepository
extends
Repository
<
City
,
Long
>
{
Page
<
City
>
findAll
(
Pageable
pageable
);
City
findByNameAndStateAllIgnoringCase
(
String
name
,
String
state
);
}
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/mongodb/databasefactory/MyBean.java
0 → 100644
View file @
02cc7789
/*
* Copyright 2012-2021 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
*
* https://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
.
docs
.
springbootfeatures
.
nosql
.
mongodb
.
databasefactory
;
import
com.mongodb.client.MongoCollection
;
import
com.mongodb.client.MongoDatabase
;
import
org.bson.Document
;
import
org.springframework.data.mongodb.MongoDatabaseFactory
;
import
org.springframework.stereotype.Component
;
@Component
public
class
MyBean
{
private
final
MongoDatabaseFactory
mongo
;
public
MyBean
(
MongoDatabaseFactory
mongo
)
{
this
.
mongo
=
mongo
;
}
// @fold:on // ...
public
MongoCollection
<
Document
>
someMethod
()
{
MongoDatabase
db
=
this
.
mongo
.
getMongoDatabase
();
return
db
.
getCollection
(
"users"
);
}
// @fold:off
}
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/mongodb/template/MyBean.java
0 → 100644
View file @
02cc7789
/*
* Copyright 2012-2021 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
*
* https://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
.
docs
.
springbootfeatures
.
nosql
.
mongodb
.
template
;
import
com.mongodb.client.MongoCollection
;
import
org.bson.Document
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.stereotype.Component
;
@Component
public
class
MyBean
{
private
final
MongoTemplate
mongoTemplate
;
public
MyBean
(
MongoTemplate
mongoTemplate
)
{
this
.
mongoTemplate
=
mongoTemplate
;
}
// @fold:on // ...
public
MongoCollection
<
Document
>
someMethod
()
{
return
this
.
mongoTemplate
.
getCollection
(
"users"
);
}
// @fold:off
}
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/neo4j/data/City.java
0 → 100644
View file @
02cc7789
/*
* Copyright 2012-2021 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
*
* https://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
.
docs
.
springbootfeatures
.
nosql
.
neo4j
.
data
;
public
class
City
{
}
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/neo4j/data/CityRepository.java
0 → 100644
View file @
02cc7789
/*
* Copyright 2012-2021 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
*
* https://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
.
docs
.
springbootfeatures
.
nosql
.
neo4j
.
data
;
import
java.util.Optional
;
import
org.springframework.data.neo4j.repository.Neo4jRepository
;
public
interface
CityRepository
extends
Neo4jRepository
<
City
,
Long
>
{
Optional
<
City
>
findOneByNameAndState
(
String
name
,
String
state
);
}
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/neo4j/driver/MyBean.java
0 → 100644
View file @
02cc7789
/*
* Copyright 2012-2021 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
*
* https://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
.
docs
.
springbootfeatures
.
nosql
.
neo4j
.
driver
;
import
org.neo4j.driver.Driver
;
import
org.neo4j.driver.Session
;
import
org.neo4j.driver.Values
;
import
org.springframework.stereotype.Component
;
@Component
public
class
MyBean
{
private
final
Driver
driver
;
public
MyBean
(
Driver
driver
)
{
this
.
driver
=
driver
;
}
// @fold:on // ...
public
String
someMethod
(
String
message
)
{
try
(
Session
session
=
this
.
driver
.
session
())
{
return
session
.
writeTransaction
((
transaction
)
->
transaction
.
run
(
"CREATE (a:Greeting) SET a.message = $message RETURN a.message + ', from node ' + id(a)"
,
Values
.
parameters
(
"message"
,
message
))
.
single
().
get
(
0
).
asString
());
}
}
// @fold:off
}
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/redis/MyBean.java
0 → 100644
View file @
02cc7789
/*
* Copyright 2012-2021 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
*
* https://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
.
docs
.
springbootfeatures
.
nosql
.
redis
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.stereotype.Component
;
@Component
public
class
MyBean
{
private
StringRedisTemplate
template
;
public
MyBean
(
StringRedisTemplate
template
)
{
this
.
template
=
template
;
}
// @fold:on // ...
public
Boolean
someMethod
()
{
return
this
.
template
.
hasKey
(
"spring"
);
}
// @fold:off
}
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/solr/client/MyBean.java
0 → 100644
View file @
02cc7789
/*
* Copyright 2012-2021 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
*
* https://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
.
docs
.
springbootfeatures
.
nosql
.
solr
.
client
;
import
java.io.IOException
;
import
org.apache.solr.client.solrj.SolrClient
;
import
org.apache.solr.client.solrj.SolrServerException
;
import
org.apache.solr.client.solrj.response.SolrPingResponse
;
import
org.springframework.stereotype.Component
;
@Component
public
class
MyBean
{
private
SolrClient
solr
;
public
MyBean
(
SolrClient
solr
)
{
this
.
solr
=
solr
;
}
// @fold:on // ...
public
SolrPingResponse
someMethod
()
throws
SolrServerException
,
IOException
{
return
this
.
solr
.
ping
(
"users"
);
}
// @fold:off
}
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/resttemplate/MyService.java
0 → 100644
View file @
02cc7789
/*
* Copyright 2012-2021 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
*
* https://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
.
docs
.
springbootfeatures
.
resttemplate
;
import
org.springframework.boot.web.client.RestTemplateBuilder
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.client.RestTemplate
;
@Service
public
class
MyService
{
private
final
RestTemplate
restTemplate
;
public
MyService
(
RestTemplateBuilder
restTemplateBuilder
)
{
this
.
restTemplate
=
restTemplateBuilder
.
build
();
}
public
Details
someRestCall
(
String
name
)
{
return
this
.
restTemplate
.
getForObject
(
"/{name}/details"
,
Details
.
class
,
name
);
}
}
// @chomp:file
class
Details
{
}
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/sql/r2dbc/City.java
0 → 100644
View file @
02cc7789
/*
* Copyright 2012-2021 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
*
* https://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
.
docs
.
springbootfeatures
.
sql
.
r2dbc
;
public
class
City
{
}
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/sql/r2dbc/CityRepository.java
0 → 100644
View file @
02cc7789
/*
* Copyright 2012-2021 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
*
* https://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
.
docs
.
springbootfeatures
.
sql
.
r2dbc
;
import
reactor.core.publisher.Mono
;
import
org.springframework.data.repository.Repository
;
public
interface
CityRepository
extends
Repository
<
City
,
Long
>
{
Mono
<
City
>
findByNameAndStateAllIgnoringCase
(
String
name
,
String
state
);
}
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/sql/r2dbc/CustomizeR2dbcPortConfiguration.java
0 → 100644
View file @
02cc7789
/*
* Copyright 2012-2021 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
*
* https://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
.
docs
.
springbootfeatures
.
sql
.
r2dbc
;
import
io.r2dbc.spi.ConnectionFactoryOptions
;
import
org.springframework.boot.autoconfigure.r2dbc.ConnectionFactoryOptionsBuilderCustomizer
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
@Configuration
public
class
CustomizeR2dbcPortConfiguration
{
// tag::code[]
@Bean
public
ConnectionFactoryOptionsBuilderCustomizer
connectionFactoryPortCustomizer
()
{
return
(
builder
)
->
builder
.
option
(
ConnectionFactoryOptions
.
PORT
,
5432
);
}
// end::code[]
}
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/sql/r2dbc/CustomizeR2dbcPostgresOptionsConfiguration.java
0 → 100644
View file @
02cc7789
/*
* Copyright 2012-2021 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
*
* https://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
.
docs
.
springbootfeatures
.
sql
.
r2dbc
;
import
java.util.HashMap
;
import
java.util.Map
;
import
io.r2dbc.postgresql.PostgresqlConnectionFactoryProvider
;
import
org.springframework.boot.autoconfigure.r2dbc.ConnectionFactoryOptionsBuilderCustomizer
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
@Configuration
public
class
CustomizeR2dbcPostgresOptionsConfiguration
{
// tag::code[]
@Bean
public
ConnectionFactoryOptionsBuilderCustomizer
postgresCustomizer
()
{
Map
<
String
,
String
>
options
=
new
HashMap
<>();
options
.
put
(
"lock_timeout"
,
"30s"
);
options
.
put
(
"statement_timeout"
,
"60s"
);
return
(
builder
)
->
builder
.
option
(
PostgresqlConnectionFactoryProvider
.
OPTIONS
,
options
);
}
// end::code[]
}
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/sql/r2dbc/databaseclient/MyBean.java
0 → 100644
View file @
02cc7789
/*
* Copyright 2012-2021 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
*
* https://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
.
docs
.
springbootfeatures
.
sql
.
r2dbc
.
databaseclient
;
import
java.util.Map
;
import
reactor.core.publisher.Flux
;
import
org.springframework.r2dbc.core.DatabaseClient
;
import
org.springframework.stereotype.Component
;
@Component
public
class
MyBean
{
private
final
DatabaseClient
databaseClient
;
public
MyBean
(
DatabaseClient
databaseClient
)
{
this
.
databaseClient
=
databaseClient
;
}
// @fold: on // ...
public
Flux
<
Map
<
String
,
Object
>>
someMethod
()
{
return
this
.
databaseClient
.
sql
(
"select * from user"
).
fetch
().
all
();
}
// @fold: off
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment