From 69d949e1deb320c4b32b225fe98234ebfba1e825 Mon Sep 17 00:00:00 2001 From: zf Date: Wed, 4 Jul 2018 14:39:49 +0800 Subject: [PATCH] fff --- README.md | 0 .../com/forezp/SpringbootElkApplication.java | 8 +- .../src/main/resources/application.properties | 0 .../src/main/resources/log4j.properties | 2 +- .../forezp/SpringbootElkApplicationTests.java | 0 .../forezp/SpringbootMongodbApplication.java | 25 ++++++ .../src/main/resources/application.properties | 11 +++ .../SpringbootMongodbApplicationTests.java | 2 + .../com/forezp/{Runner.java => Sender.java} | 72 +++++++++--------- .../forezp/SpringbootRabbitmqApplication.java | 15 ++-- .../java/com/forezp/message/Receiver.java | 3 + .../src/main/resources/application.properties | 4 + .../src/main/resources/application.properties | 4 +- springboot-upload-file/upload-dir/212.jpg | Bin 14 files changed, 95 insertions(+), 51 deletions(-) mode change 100644 => 100755 README.md mode change 100644 => 100755 springboot-elk/src/main/java/com/forezp/SpringbootElkApplication.java mode change 100644 => 100755 springboot-elk/src/main/resources/application.properties mode change 100644 => 100755 springboot-elk/src/test/java/com/forezp/SpringbootElkApplicationTests.java rename springboot-rabbitmq/src/main/java/com/forezp/{Runner.java => Sender.java} (75%) mode change 100644 => 100755 springboot-upload-file/upload-dir/212.jpg diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/springboot-elk/src/main/java/com/forezp/SpringbootElkApplication.java b/springboot-elk/src/main/java/com/forezp/SpringbootElkApplication.java old mode 100644 new mode 100755 index c0a9907..dfaf2b9 --- a/springboot-elk/src/main/java/com/forezp/SpringbootElkApplication.java +++ b/springboot-elk/src/main/java/com/forezp/SpringbootElkApplication.java @@ -1,15 +1,19 @@ package com.forezp; +import org.apache.log4j.Logger; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class SpringbootElkApplication { + private static Logger LOGGER = Logger.getLogger(SpringbootElkApplication.class); + public static void main(String[] args) { SpringApplication.run(SpringbootElkApplication.class, args); + for(int i = 0; i < 1000; i ++){ + LOGGER.info("i is " + i); + } } - - } diff --git a/springboot-elk/src/main/resources/application.properties b/springboot-elk/src/main/resources/application.properties old mode 100644 new mode 100755 diff --git a/springboot-elk/src/main/resources/log4j.properties b/springboot-elk/src/main/resources/log4j.properties index 28307cf..b572a24 100755 --- a/springboot-elk/src/main/resources/log4j.properties +++ b/springboot-elk/src/main/resources/log4j.properties @@ -7,7 +7,7 @@ log4j.logger.com.forezp=DEBUG, socket # appender socket log4j.appender.socket=org.apache.log4j.net.SocketAppender -log4j.appender.socket.Port=4560 +log4j.appender.socket.Port=14560 log4j.appender.socket.RemoteHost=localhost log4j.appender.socket.layout=org.apache.log4j.PatternLayout log4j.appender.socket.layout.ConversionPattern=%d [%-5p] [%l] %m%n diff --git a/springboot-elk/src/test/java/com/forezp/SpringbootElkApplicationTests.java b/springboot-elk/src/test/java/com/forezp/SpringbootElkApplicationTests.java old mode 100644 new mode 100755 diff --git a/springboot-mongodb/src/main/java/com/forezp/SpringbootMongodbApplication.java b/springboot-mongodb/src/main/java/com/forezp/SpringbootMongodbApplication.java index d952136..361530d 100755 --- a/springboot-mongodb/src/main/java/com/forezp/SpringbootMongodbApplication.java +++ b/springboot-mongodb/src/main/java/com/forezp/SpringbootMongodbApplication.java @@ -7,6 +7,11 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import javax.net.ssl.*; +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; +import java.security.cert.X509Certificate; + /** * 启动mongodb * C:\Program Files\MongoDB\Server\3.4\bin @@ -19,7 +24,27 @@ public class SpringbootMongodbApplication implements CommandLineRunner { @Autowired private CustomerRepository repository; + static { + //for localhost testing only + javax.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier( + new javax.net.ssl.HostnameVerifier(){ + + public boolean verify(String hostname, + javax.net.ssl.SSLSession sslSession) { + if (hostname.equals("192.168.8.104")) { + return true; + } + return false; + } + }); + } + + + public static void main(String[] args) { + System.setProperty("javax.net.ssl.trustStore", "/etc/ssl/nx.keystore"); + + System.setProperty("javax.net.ssl.trustStorePassword", "1234567890"); SpringApplication.run(SpringbootMongodbApplication.class, args); } diff --git a/springboot-mongodb/src/main/resources/application.properties b/springboot-mongodb/src/main/resources/application.properties index e69de29..bce9f6e 100755 --- a/springboot-mongodb/src/main/resources/application.properties +++ b/springboot-mongodb/src/main/resources/application.properties @@ -0,0 +1,11 @@ +spring.data.mongodb.uri=mongodb://www.localhost.com:27017/push_message_db?ssl=true +#spring.data.mongodb.host=192.168.8.104 +#spring.data.mongodb.port=27017 +#spring.data.mongodb.repositories.enabled=true +#spring.data.mongodb.database=nx + + + +#spring.data.mongodb.host=192.168.8.104 +#spring.data.mongodb.port=27017 +#spring.data.mongodb.database=nx diff --git a/springboot-mongodb/src/test/java/com/forezp/SpringbootMongodbApplicationTests.java b/springboot-mongodb/src/test/java/com/forezp/SpringbootMongodbApplicationTests.java index 12462f9..fcd9985 100755 --- a/springboot-mongodb/src/test/java/com/forezp/SpringbootMongodbApplicationTests.java +++ b/springboot-mongodb/src/test/java/com/forezp/SpringbootMongodbApplicationTests.java @@ -5,6 +5,7 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; + @RunWith(SpringRunner.class) @SpringBootTest public class SpringbootMongodbApplicationTests { @@ -13,4 +14,5 @@ public class SpringbootMongodbApplicationTests { public void contextLoads() { } + } diff --git a/springboot-rabbitmq/src/main/java/com/forezp/Runner.java b/springboot-rabbitmq/src/main/java/com/forezp/Sender.java similarity index 75% rename from springboot-rabbitmq/src/main/java/com/forezp/Runner.java rename to springboot-rabbitmq/src/main/java/com/forezp/Sender.java index c154522..db10445 100755 --- a/springboot-rabbitmq/src/main/java/com/forezp/Runner.java +++ b/springboot-rabbitmq/src/main/java/com/forezp/Sender.java @@ -1,38 +1,36 @@ -package com.forezp; - -import java.util.concurrent.TimeUnit; - - -import com.forezp.message.Receiver; -import org.springframework.amqp.rabbit.core.RabbitTemplate; -import org.springframework.boot.CommandLineRunner; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.stereotype.Component; - -@Component -public class Runner implements CommandLineRunner { - - private final RabbitTemplate rabbitTemplate; - private final Receiver receiver; - private final ConfigurableApplicationContext context; - - public Runner(Receiver receiver, RabbitTemplate rabbitTemplate, - ConfigurableApplicationContext context) { - this.receiver = receiver; - this.rabbitTemplate = rabbitTemplate; - this.context = context; - } - - @Override - public void run(String... args) throws Exception { - System.out.println("Sending message..."); - rabbitTemplate.convertAndSend(SpringbootRabbitmqApplication.queueName, "Hello from RabbitMQ!"); - receiver.getLatch().await(10000, TimeUnit.MILLISECONDS); - context.close(); - } - - /** - * Sending message... - Received - */ +package com.forezp; + +import java.util.concurrent.TimeUnit; + + +import com.forezp.message.Receiver; +import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.boot.CommandLineRunner; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.stereotype.Component; + +/** + * 生产者 + */ +@Component +public class Sender implements CommandLineRunner { + + private final RabbitTemplate rabbitTemplate; + private final Receiver receiver; + private final ConfigurableApplicationContext context; + + public Sender(Receiver receiver, RabbitTemplate rabbitTemplate, + ConfigurableApplicationContext context) { + this.receiver = receiver; + this.rabbitTemplate = rabbitTemplate; + this.context = context; + } + + @Override + public void run(String... args) throws Exception { + System.out.println("Sending message..."); + rabbitTemplate.convertAndSend(SpringbootRabbitmqApplication.queueName, "zf: Hello World!"); + receiver.getLatch().await(10000, TimeUnit.MILLISECONDS); + //context.close(); + } } \ No newline at end of file diff --git a/springboot-rabbitmq/src/main/java/com/forezp/SpringbootRabbitmqApplication.java b/springboot-rabbitmq/src/main/java/com/forezp/SpringbootRabbitmqApplication.java index 2ae451c..85c9470 100755 --- a/springboot-rabbitmq/src/main/java/com/forezp/SpringbootRabbitmqApplication.java +++ b/springboot-rabbitmq/src/main/java/com/forezp/SpringbootRabbitmqApplication.java @@ -1,10 +1,7 @@ package com.forezp; import com.forezp.message.Receiver; -import org.springframework.amqp.core.Binding; -import org.springframework.amqp.core.BindingBuilder; -import org.springframework.amqp.core.Queue; -import org.springframework.amqp.core.TopicExchange; +import org.springframework.amqp.core.*; import org.springframework.amqp.rabbit.connection.ConnectionFactory; import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; import org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter; @@ -16,7 +13,7 @@ @SpringBootApplication public class SpringbootRabbitmqApplication { - final static String queueName = "spring-boot"; + final static String queueName = "onlyoffice-client-queue2"; @Bean Queue queue() { @@ -24,13 +21,13 @@ Queue queue() { } @Bean - TopicExchange exchange() { - return new TopicExchange("spring-boot-exchange"); + FanoutExchange exchange(){ + return new FanoutExchange("onlyoffice-client-exchange-file2"); } @Bean - Binding binding(Queue queue, TopicExchange exchange) { - return BindingBuilder.bind(queue).to(exchange).with(queueName); + Binding binding(Queue queue, FanoutExchange exchange) { + return BindingBuilder.bind(queue).to(exchange); } @Bean diff --git a/springboot-rabbitmq/src/main/java/com/forezp/message/Receiver.java b/springboot-rabbitmq/src/main/java/com/forezp/message/Receiver.java index df321fe..2b3a6f4 100755 --- a/springboot-rabbitmq/src/main/java/com/forezp/message/Receiver.java +++ b/springboot-rabbitmq/src/main/java/com/forezp/message/Receiver.java @@ -3,6 +3,9 @@ import java.util.concurrent.CountDownLatch; import org.springframework.stereotype.Component; +/** + * 消费者 + */ @Component public class Receiver { diff --git a/springboot-rabbitmq/src/main/resources/application.properties b/springboot-rabbitmq/src/main/resources/application.properties index e69de29..b6aa23d 100755 --- a/springboot-rabbitmq/src/main/resources/application.properties +++ b/springboot-rabbitmq/src/main/resources/application.properties @@ -0,0 +1,4 @@ +spring.rabbitmq.host=192.168.8.253 +spring.rabbitmq.port=5672 +spring.rabbitmq.username=guest +spring.rabbitmq.password=guest \ No newline at end of file diff --git a/springboot-redis-message/src/main/resources/application.properties b/springboot-redis-message/src/main/resources/application.properties index 31fa2ba..e597134 100755 --- a/springboot-redis-message/src/main/resources/application.properties +++ b/springboot-redis-message/src/main/resources/application.properties @@ -1,5 +1,5 @@ -spring.redis.host=localhost -spring.redis.port=6379 +spring.redis.host=10.111.55.199 +spring.redis.port=63799 #spring.redis.password= spring.redis.database=1 spring.redis.pool.max-active=8 diff --git a/springboot-upload-file/upload-dir/212.jpg b/springboot-upload-file/upload-dir/212.jpg old mode 100644 new mode 100755