全 #Lesley [Legend V] #MVP 7.7/6 4 6 | $13383 202206142025 https://youtu.be/tnp0nELuY8Q via @YouTube #MLBB
2022-07-13
全 #Lesley [Legend V] #MVP 7.7/6 4 6 | $13383 202206142025
全 #Lesley [Legend V] #MVP 7.7/6 4 6 | $13383 202206142025 https://youtu.be/tnp0nELuY8Q via @YouTube #MLBB
Java does new instance consume many memory
Found: https://stackoverflow.com/a/258150
Measurement methods
You can use Instrumentation.getObjectSize() to obtain an estimate of the storage consumed by an object.
eclipse maven "JUnit" "javaagent"
eclipse maven "JUnit" "javaagent"
Found this:
You can use ea-agent-loader
With it loading an agent in runtime will look like:
public class HelloAgentWorld
{
public static class HelloAgent
{
public static void agentmain(String agentArgs, Instrumentation inst)
{
System.out.println(agentArgs);
System.out.println("Hi from the agent!");
System.out.println("I've got instrumentation!: " + inst);
}
}
public static void main(String[] args)
{
AgentLoader.loadAgentClass(HelloAgent.class.getName(), "Hello!");
}
}
全 #Rafaela [Epic I] #MVP 9.6/4 3 21 | $8313 202205281332 https://youtu.be/jUNpF3a8HPI via @YouTube #MLBB
全 #Rafaela [Epic I] #MVP 9.6/4 3 21 | $8313 202205281332 https://youtu.be/jUNpF3a8HPI via @YouTube #MLBB
2022-07-12
eclipse added hotkey for svn actions are not working.
It may be due to this breaking change in Eclipse 3.6:
EDIT:
Looks like it definitely is. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=309074. Here's the fix:
In the "Customize Perspective" dialog, go to the "Command Groups Availability" tab and check "Team" and "SVN".
In Eclipse Mars.2 (4.5.2) this is under Window->Perspective->Customize Perspective... dialog, "Action Set Availability" tab. (Try to restart Eclipse if it doesn't work after you change it). Customize Perspective dialog screenshot
Right click on current perspective:
2022-07-06
Resolved - @PreUpdate not working in JUnit test.
javax.persistence.PreUpdate
object need to be "dirty" to trigger...
obj.setColumn01("new text);
repo.save(obj);
Solution
As you said, the callback method is called the second time, if the entity is detached or fetched again from DB.
I cannot explain it exactly, but can think of the scenario described here, when no dirty fields are identified before the second save() call and thus the @PreUpdate callback not called. Or it may be simply a bug within your version of EclipseLink.
2022-07-01
Setup local Keycloak for development
https://stackoverflow.com/a/72600716
We are sorry... page not found... error
If config below never in place, will trigger error: Invalid parameter: redirect_uri
Valid Redirect URIs: *
Different of SVNs
Getting(install) SVN feature from
Eclipse Marketplace...
http://subclipse.tigris.org/update_1.6.x
subclipse.tigris.org no longer available...
2022-06-10
"Spring" JPA "native query" java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
"Spring" JPA "native query" java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
Exception Snippet:
Throw error with:
List<Map<String, Object>> getNativeQueryList();
or
List<Tuple> getNativeQueryList();
Work around with:
List<Object[]> getNativeQueryList();
JUnit test - Caused by: javax.persistence.RollbackException: Transaction marked as rollbackOnly
Exception snippet:
@Rollback(false)
MyJUnitTestClass
@Rollback(true)
2022-05-31
Alternative - Error Code: 1093. You can't specify target table 'YOUR_TABLE' for update in FROM clause
Error Code: 1093. You can't specify target table 'YOUR_TABLE' for update in FROM clause
UPDATE YOUR_TABLE SET columnA = 'def' WHERE id IN (SELECT id AS MMID FROM YOUR_TABLE WHERE columnA = 'abc');
UPDATE YOUR_TABLE SET columnA = 'def' WHERE id IN ( SELECT MMID FROM ( SELECT id AS MMID FROM YOUR_TABLE WHERE columnA = 'abc' ) AS YOUR_ALIAS );
2022-04-20
JasperReport, always get blank PDF?
line below with new JREmptyDataSource() will get pdf as per expected.
jasperPrint = JasperFillManager.fillReport(report, jrParam, new JREmptyDataSource());
vs
2022-04-14
Multiple JasperPrint into a pdf with output as file and byte[]
JasperExportManager.exportReportToPdf vs JRPdfExporter.exportReport()
Found: https://community.jaspersoft.com/questions/526021/how-merge-multiple-pdf-jasper-reports-one
public void pdf() throws JRException { long start = System.currentTimeMillis(); List<JasperPrint> jasperPrintList = new ArrayList<JasperPrint>(); jasperPrintList.add((JasperPrint)JRLoader.loadObjectFromFile("build/reports/Report1.jrprint")); jasperPrintList.add((JasperPrint)JRLoader.loadObjectFromFile("build/reports/Report2.jrprint")); jasperPrintList.add((JasperPrint)JRLoader.loadObjectFromFile("build/reports/Report3.jrprint")); JRPdfExporter exporter = new JRPdfExporter(); exporter.setExporterInput(SimpleExporterInput.getInstance(jasperPrintList)); exporter.setExporterOutput(new SimpleOutputStreamExporterOutput("build/reports/BatchExportReport.pdf")); SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration(); configuration.setCreatingBatchModeBookmarks(true); exporter.setConfiguration(configuration); exporter.exportReport(); System.err.println("PDF creation time : " + (System.currentTimeMillis() - start)); }
JRPdfExporter to byte array
public byte[] exportToPdf(JasperPrint jasperPrint) throws JRException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); JRPdfExporter exporter = new JRPdfExporter(jasperReportsContext); exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(baos)); exporter.exportReport(); return baos.toByteArray(); }
more Java JRPdfExporter.exportReport方法代碼示例
2022-04-13
Resolved: No qualifying bean of type 'org.springframework.boot.web.client.RestTemplateBuilder'
JUnit
org.springframework.boot.test.autoconfigure.web.client.AutoConfigureWebClient
org.springframework.test.context.ContextConfiguration
public class LocalConfig {/****/public LocalConfig() {}@Beanpublic RestTemplate restTemplate(RestTemplateBuilder builder) {// Do any additional configuration herereturn builder.build();}}
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.boot.web.client.RestTemplateBuilder' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
org.springframework.beans.factory.BeanFactory.getBean( ) with args
Source URL: https://www.programcreek.com/java-api-examples/?class=org.springframework.beans.factory.BeanFactory&method=getBean
public static void main(String[] args) { // 配置 XML 配置文件 // 启动 Spring 应用上下文 BeanFactory beanFactory = new ClassPathXmlApplicationContext("classpath:/META-INF/bean-instantiation-context.xml"); User user = beanFactory.getBean("user-by-static-method", User.class); User userByInstanceMethod = beanFactory.getBean("user-by-instance-method", User.class); User userByFactoryBean = beanFactory.getBean("user-by-factory-bean", User.class); System.out.println(user); System.out.println(userByInstanceMethod); System.out.println(userByFactoryBean); System.out.println(user == userByInstanceMethod); System.out.println(user == userByFactoryBean); }
2022-04-12
@RunWith vs @SpringBootTest
https://stackoverflow.com/questions/58901288/springrunner-vs-springboottest
@RunWith(SpringRunner.class) : You need this annotation to just enable spring boot features like @Autowire, @MockBean etc.. during junit testing
is used to provide a bridge between Spring Boot test features and JUnit. Whenever we are using any Spring Boot testing features in our JUnit tests, this annotation will be required.
@SpringBootTest : This annotation is used to load complete application context for end to end integration testing
The @SpringBootTest annotation can be used when we need to bootstrap the entire container. The annotation works by creating the ApplicationContext that will be utilized in our tests.
Here is the article with clear examples on both scenarios Baeldung