Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

Zaphod42 posted:

I know, its all compiler-time, not run-time. But still, readability.

Lombok in Java does the same thing.

I limit it's use for when I'm in the same function and I just told you the type on the RHS of the =. Never as the assignment of a method call that returns something, that's just killing your readability as you said.

Adbot
ADBOT LOVES YOU

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe
Do you have the HTML structure for your page figured out? What are you using for your view (JSP, thymeleaf, are you writing out HTML in your servlet)? In any case what you want is a servlet that has a URL mapping like
pre:
/car/{VIN}
In the servlet code you'd get the VIN number from the URL and then do a lookup to get all the rest of the information. Once you have that info you send it to your view layer so that it renders the page with the new info. Not sure if that answers your question, but hopefully gets you going.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

Hippie Hedgehog posted:

Yes. Infinitely yes.

(Protip: Don't assume Java advice from your time at uni is still valid. The language and tool chain have both improved immensely from even 5 years ago. Me, I learned in Emacs but once I was working, we use first Netbeans, then Eclipse, then finally IntelliJ came along and I didn't have to wait for the freaking IDE to catch up with my typing any longer.)

Look at this guys granytyping, not double VPN jumping like he should.

seriously pray you don't have to do any coding in a java ide over remote desktop, it's the worst

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe
I sent you a PM, hit me up if you want to do a live debug over GChat

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

Guildenstern Mother posted:

I'm working on a project with a buddy and when I go to run his latest push I'm getting this error.
code:
APPLICATION FAILED TO START
***************************

Description:

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

Reason: Failed to determine a suitable driver class
Application properties in question:

code:
spring.mvc.view.prefix=/WEB-INF/
spring.datasource.url=jdbc:mysql://localhost:3306/moto
spring.datasource.username=****
spring.datasource.password=****
spring.jpa.hibernate.ddl-auto=update
spring.mvc.hiddenmethod.filter.enabled=true
spring.jackson.serialization.write-dates-as-timestamps: false
adding these lines didn't fix it, but I'm pretty sure the problem is something related to the bolded one that needs fixing
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.database-platform = org.hibernate.dialect.MySQL5Dialect
spring.jpa.generate-ddl=true


I'm assuming something in application properties is the culprit, but stackoverflow also told me that adding this line: @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class }) would fix it but didn't make any mention of where to put it. Application properties? I've never seen anything starting with an @ in there, but I'm an idiot so maybe that's normal.
edit: It goes in the main application class duh. Fixed the first problem but now its giving me all sorts of bean errors in my service classes so I'm not sure that was the solution I needed.

I would expect that to happen since you are telling Spring to not start the DataSourceAutoConfiguration which would create the Bean needed by all of your data classes, so of course they are complaining about a missing bean. That kind of fix is like my monitor looks fuzzy, solution: unplug it.

It could be a few issues, the properties you are setting are not the ones that Spring is looking for. i.e it can't find the URL because it's looking for it under a different prefix i.e. when using a connection pool. But I doubt this is your case since you are just trying to get it to talk to a single mysql db instance.
I am going to guess and say that your mysql driver is not somewhere on the classpath that Spring can find. It does something on startup that registers the driver as something that can handle the jdbc:mysql url. If it's not on the classpath then the URL isn't going to work and leads to the kind of errors you are seeing. I recall having to manually put the jdbc driver in a tomcat folder, but I thought new Spring Boot stuff got rid of that. Still worth a shot to make sure the mysql driver is getting loaded in the embedded application server.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe
I recall using an Enum to express the states of the SM and then creating a SM interface that defined the actions and the Enum implement it. In each enum I then had to define the action and return the next state. Then I created a execution class that would take that SM interface and basically just go through a loop until it reaches a terminal state. I don't know if it could be made simpler with the newer Java versions, but that should give you an idea.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe
When I'm having trouble with lambdas I first try to write things as a function and then turn them into a lambda. In this case you just have a really convoluted boolean expression,

Java code:
boolean isGoodFruit(Fruit x){
	return x.getWeight() >= 15 && (x.getAge() <= 30 || x.hasHardShell()) && !"brown".equals(x.getColor())
}
Note that your age check was backwards, and I switched the color check (this is safer in case x.getColor() returns null). Also I'm not sure what the hardshell check should do, pass all fruits that have a hard shell regardless of age or not pass any of them.

If you're sure that functions passes all the criteria you want, then you can convert it into a lambda easily.
Java code:
Fruit[] goodFruits = Arrays.stream(fruits).filter(x -> x.getWeight() >= 15 && (x.getAge() <= 30 || x.hasHardShell()) && !"brown".equals(x.getColor())).toArray();

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe
It seems like there is a specific type for the FruitInspector that has a pass method. Lambdas let you create a quick implementations of these simple interfaces and I'm guessing in this case this should work

Java code:
FruitInspector goodInspector = (x) -> x.getWeight() >= 15 && (x.getAge() <= 30 || x.hasHardShell()) && !"brown".equals(x.getColor());

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe
I really dislike teaching newbies the streaming APIs, what was wrong with doing it the old fashioned way with for loops. I feel like stuff was so much simpler to reason about.

Adbot
ADBOT LOVES YOU

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

Tempora Mutantur posted:

(the answer will be "because their management pays you to write it using vert.x" but I'd like to know if there's an actual good reason)

Seriously dude, you think working at any of the FAANG companies will get your relevant experience in technology X, only to find that internally they use some janky custom built poo poo that then spawned into the frameworks you love.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply