Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7672633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:19:51+00:00 2026-05-31T16:19:51+00:00

I try to write if else condition on Entity class but when i run

  • 0

I try to write if else condition on Entity class but when i run tomcat it’s not working. It have an error. I curious to know how to write if else condition in spring roo project? And which file i can write that?

i try to test condition by write:(in Student.java)

  9 @RooJavaBean
 10 @RooToString
 11 @RooJpaActiveRecord
 12 public class Student {
 13     private long id;
 14     private String name; 
 15     private Integer age; 
 16     if(true){} //test if condition

And this’s errors when i run tomcat.

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project tap: Compilation failure: Compilation failure:
[ERROR] Employee.java:[22,1] illegal start of type
[ERROR] Employee.java:[22,4] illegal start of type
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T16:19:52+00:00Added an answer on May 31, 2026 at 4:19 pm

    The failure indicate that you have an syntax error.

    And yes there in an syntax error in line 16.
    You can not write an if statement somewhere into an class, it must be in an method!

    @RooJavaBean
    @RooToString
    @RooJpaActiveRecord
    public class Student {
       private long id;
       private String name; 
       private Integer age; 
    
       public void someMethod() {
           if(1 == 1){
              // if 1 is 1 then do this.
           } else {
             // if 1 is different to 1 then do this.
           }                
       }
    

    You should notice, that this Roo classes, are normal Java classes (enhannced by some Roo generated AspectJ files), but this are real classes, but no configuration files.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try to write a daemon in python. But I have no idea how
I try to write to a large file, but it seems like it does
I try to write :ab in Vim for faster coding but the question is
I try to write a site with CodeIgniter but I've a problem with PHP.
i try to write my own control.But my control' html has problem: Look like
I have a piece of C code where I try to write a buffer
I try to write KSH script for processing a file consisting of name-value pairs,
I try to write a simple client/server application (all application is a bluetooth service
I try to write a simple Markdown parser in JavaScript. Therefore I want to
I try to write a macro in clojure that sets up a namespace and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.