In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Docker maven plug-in how to use, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.
What is Docker?
Docker has been very popular in the industry recently. If you don't know what Docker is yet, you should be careful. In the future, you will find yourself using it in some way. This article assumes that you already have a foundation for Docker. If you are not familiar with it now, I am sure you will come to read this article in the future.
Docker is ideal for integration testing and complex distributed system demonstration. It can even be used to run systems in a production environment. It is an open source software container. You can think of it as a very light, super fast virtual machine.
Examples
Inspired by the "Integration testing with Maven and Docker" article and the Docker Java API project, I wrote a simple maven plug-in that can manage Docker containers, Docker Maven Plugin. According to your configuration, the plug-in will start the container during the build, stop the container at the end of the build and delete it. If the image cannot be found locally, Docker will automatically download it from the central repository.
The following integration tests with Apache Camel are ignored because they require an instance of Redis to be executed:
Package org.apache.camel.component.redis; import org.apache.camel.impl.JndiRegistry; import org.junit.Ignore; import org.junit.Test; import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; import org.springframework.data.redis.core.RedisTemplate; @ Ignore public class RedisProducerIntegrationTest extends RedisTestSupport {private static final JedisConnectionFactory CONNECTION_FACTORY = new JedisConnectionFactory () Static {CONNECTION_FACTORY.afterPropertiesSet ();} @ Override protected JndiRegistry createRegistry () throws Exception {JndiRegistry registry = super.createRegistry (); redisTemplate = new RedisTemplate () RedisTemplate.setConnectionFactory (CONNECTION_FACTORY); redisTemplate.afterPropertiesSet (); registry.bind ("redisTemplate", redisTemplate); return registry } @ Test public void shouldSetAString () throws Exception {sendHeaders (RedisConstants.COMMAND, "SET", RedisConstants.KEY, "key1", RedisConstants.VALUE, "value") AssertEquals ("value", redisTemplate.opsForValue () .get ("key1"));} @ Test public void shouldGetAString () throws Exception {redisTemplate.opsForValue () .set ("key2", "value") Object result = sendHeaders (RedisConstants.KEY, "key2", RedisConstants.COMMAND, "GET"); assertEquals ("value", result);}
We configure docker-maven-plugin to use a Redis image while mapping port 6379 of the host to port 6379 of the container:
Com.ofbizian docker-maven-plugin 1.0.0 dockerfile/redis Start-docker pre-integration-test Start stop-docker post-integration-test stop Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.