这里分类和汇总了欣宸的全部原创(含配套源码):https://github.com/zq2599/blog_demos
package com.bolingcavalry;
import com.bolingcavalry.service.impl.NormalApplicationScoped;
import com.bolingcavalry.service.impl.NormalSingleton;
import io.quarkus.logging.Log;
import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.Test;
import javax.inject.Inject;
@QuarkusTest
class ChangeLazyLogicTest {
@Inject
NormalSingleton normalSingleton;
@Inject
NormalApplicationScoped normalApplicationScoped;
@Test
void ping() {
Log.info("start invoke normalSingleton.ping");
normalSingleton.ping();
Log.info("start invoke normalApplicationScoped.ping");
normalApplicationScoped.ping();
}
}
package com.bolingcavalry.service.impl;
import io.quarkus.logging.Log;
import javax.inject.Singleton;
@Singleton
public class NormalSingleton {
public NormalSingleton() {
Log.info("Construction from " + this.getClass().getSimpleName());
}
public String ping() {
return "ping from NormalSingleton";
}
}
package com.bolingcavalry;
import com.bolingcavalry.service.impl.NormalApplicationScoped;
import com.bolingcavalry.service.impl.NormalSingleton;
import io.quarkus.logging.Log;
import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.Test;
import javax.inject.Inject;
@QuarkusTest
class ChangeLazyLogicTest {
@Inject
NormalSingleton normalSingleton;
@Inject
NormalApplicationScoped normalApplicationScoped;
@Test
void ping() {
Log.info("start invoke normalSingleton.ping");
normalSingleton.ping();
Log.info("start invoke normalApplicationScoped.ping");
normalApplicationScoped.ping();
}
}
@ApplicationScoped
@Startup
public class NormalApplicationScoped {
创作打卡挑战赛
赢取流量/现金/CSDN周边激励大奖
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://xinchen.blog.csdn.net/article/details/124524910
内容来源于网络,如有侵权,请联系作者删除!