osx sierra intellij spring boot jdk 8 slow startup

My spring boot applications startup time was very long with jdk 8. There is no problem with jdk 9. A simple application without any code startup time was over 15 seconds. Now it starts under 5 seconds. I find solution in stackoverflow :

solved the problem by adding my Mac hostname (i.e. Macbook.local, or whatever your Mac is called) on the /etc/hosts file mapped to the 127.0.0.1 address as well as the ::1 like this:

127.0.0.1   localhost mbpro.local
::1         localhost mbpro.local

To learn your hostname, type hostname in the console.

https://stackoverflow.com/questions/39636792/jvm-takes-a-long-time-to-resolve-ip-address-for-localhost

Integrating Angular and Spring Boot in one project and running on one server

 

  1. After creating spring boot project to create Angular project on the same folder :
    From root directory firstly go upper directory

    cd ..

    create new ng project with same spring boot directory name (example: bootang) , and i set src/main/app for Angular source

    ng new bootang -sd src/main/app
  2. Change output directory for Angular output in .angular-cli.json :
    "outDir": "src/main/webapp",
  3. Build angular app :
    ng build

    If you run with -w (watch) parameter, it will refresh angular build files.
    Like ng serve

    ng build -w
  4. Run your spring boot application and you will see Spring Boot and Angular runs on same server (default localhost:8080)I think this way is better/simple than JHipster ‘s lots of webpack configuration 🙂

Hibernate Auditing – Base Entity and Example Entity

Add @EnableJpaAuditing to spring boot config class

@Configuration
@EnableJpaAuditing
public class AppConfiguration {

Add Hibernate envers dependency to your pom.xml file :

<dependency>
   <groupId>org.hibernate</groupId>
   <artifactId>hibernate-envers</artifactId>
   <version>${hibernate.version}</version>
</dependency>

This is base entity class for enabling auditing :

@MappedSuperclass
@Audited
@EntityListeners(AuditingEntityListener.class)
@Data
public class BaseEntity implements Serializable{

    private static final long serialVersionUID = -1591130256151148932L;

    @CreatedBy
    private String createdBy;

    @CreatedDate
    private Date createdDate;

    @LastModifiedBy
    private String updatedBy;

    @LastModifiedDate
    private Date updatedDate;
}

Example User entity extends BaseEntity :

@Data
@Entity
@EqualsAndHashCode(callSuper=false)
public class User extends BaseEntity implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @Column(length = 100,unique = true,nullable = false)
    private String login;

    private String password;
    private String firstName;
    private String lastName;
    private boolean active = false;
    @Email
    private String email;

    @ManyToMany
    @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
    private Set<Role> roles = new HashSet<>();
}

If a relationship entity in your entity is not audited, then you should add annotation  :
@Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)

For adding for example “ZLOG_” prefix to your audit tables in your spring boot application.yml file :

spring:
  jpa:
    properties:
      org.hibernate.envers.audit_table_prefix: ZLOG_

Issue with the rowEdit event in p:dataTable Primefaces component

The issue was in the following: when I try to edit row in the dataTable, all is going well. But when I try to save the changes, the new value doesn’t retrieve and new value has not been saved.

In the getAll method of the generic dao do null control :

if (listItems == null){
            listItems = (List<Item>) genericDao.getAll();
        }
        return listItems;

source : http://jwsn.blogspot.com.tr/2013/05/issue-with-rowedit-event-in-primefaces.html

glassfish hibernate binding parameters, easy way

when you search for showing parameters in hibernate. All articles will say that put these lines in log4j.properties :

log4j.logger.org.hibernate.SQL=debug
log4j.logger.org.hibernate.type=trace

but if you are using glassfish this will not work. and you will find this glassfish way :

https://blogs.oracle.com/naman/entry/configure_log4j_for_use_in

but there is a more easy way :

Glassfish admin console -> Configurations -> Server-config -> Logger Settings -> Log levels -> Add Logger -> org.hibernate.type : FINEST

Screen Shot 2015-01-18 at 01.58.51

glassfish logger settings

I am using intellij idea with glassfish and in the console i see this long message for every line :

[2013-01-29T15:27:39.395-0500] [glassfish 4.0] [INFO] [AS-JMX-00005] [javax.enterprise.system.jmx] [tid: _ThreadID=49 _ThreadName=Thread-6] [timeMillis: 1359491259395] [levelValue: 800] [[ …

to reduce and shorten the messages, go to  glassfish admin console -> configurations -> server-config -> logger-settings :

select all fields in the format exclude fields and click save.

Screen Shot 2015-01-18 at 00.13.35

and shorten your log4j pattern in log4j.properties. From :

log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

to this pattern :

log4j.appender.stdout.layout.ConversionPattern=%c{1}:%L - %m%n

How to Toggle Within and Between Apps in OS X

  • Toggling between open programs is Command + Tab
  • Toggling up a minimized program is Command + Tab with Option on release
  • Toggling between tabs is Command + Shift + [ or ]
  • Opening a new tab is Command + t
  • Closing a tab or window is Command + w
  • Toggling windows of the same application is Command + (next to shift in english keyboard)

source : http://computers.tutsplus.com/tutorials/how-to-toggle-within-and-between-apps-in-os-x–mac-56503

Taking screenshot of selected area on the screen to desktop: Command + Shift + 4

jsf composite component update

if you have items with different namespaces in a composite component to update one from other, using standard “:” to search in namespace will not work. You will get this exception :

Cannot find component with expression “form1” referenced from ….

You should use “@composite” in the update parameter. Example :

<cc:interface>      
</cc:interface>
<cc:implementation >
    <h:form id="form1"> </h:form>
    <h:form id="form2">
         <p:commandButton update=":form1" />  <!-- ERROR -->
         <p:commandButton update="@composite:form1" />

mysql workbench export error osx

ERROR : 
Error Unhandled exception: ‘builtin_function_or_method’ object has no attribute ‘__getitem__’this error occurs even if you try to backup a single table
SOLUTION :
In the editor, / Applications / MySQLWorkbench.app / Contents / Resources / plugins / wb_admin_export.py me’ll open.
If you check the 1712 line, certainly
args.append – it has become a [‘skip-triggers’]. Because apparently is wrong this [], I’ll change it to ().
In addition, the 1715 line
args.append – so has become [‘no-create-info’], to keep repair in as well ().
Save, I’ll start the MySQL Workbench again.
Connect to the site, export! ! ! While shouting and running.
src: http://banikojp.blogspot.com.tr/2014/12/mysql-workbencherror.html