-1

I am working on a boilerplate SpringBoot-React CRUD project as a basis for something bigger that I want to do. The project also uses MSSQL as a database and Spring JPA to interface with it.

UPDATE

Considering another angle - can it have to do with switched corporate VPNs, if the project is stored on a networked drive, or should some of the metadata in the workspace be deleted, and then re-clean and update the project?


UPDATE 2

He's dead, Jim: enter image description here


I will be still working to figure this out.

What has been frustrating is that after building the API and it working, it gets a spontaneous error that I can't explain, and which forces me to recreate the entire project. In a word, the implementation of the repository gets the "add unimplemented methods" error, when the interface itself has no methods specified. Then, I get an error in the POM file about the "MANIFEST.MF" file missing. This occurs with the API just running without a problem for a time, and then it just breaks. This has occurred a few times already, but now it's getting problematic, because I also don't have a lot of time left for the project.

For context:

Typical MVC project structure: enter image description here

The implementation error: enter image description here

Adding the unimplemented methods will result in the addition of every conceivable method in JPA, when none of them are declared in the interface: enter image description here

The interface had a declared methods that was implemented in the Controller, which was just due to a shortcoming in the example I was basing this on: enter image description here

I am suspecting that this is an STS4 issue? Coincidentally, it then doesn't stop "Computing...", again spontaneously: enter image description here

After all of the above happens, the POM file gives me the MANIFEST.MF Error: enter image description here

There is also an error at the line:

enter image description here

I have tried reinstalling the Eclipse IDE on this, I've ensured that the environment is compatible (Java 11, Spring 2.7.6, Maven, installed libs are JPA, Dev Tools, MSSQL Driver, Web - typical ones for the sort of the project). SQL configuration also worked correctly before, with the connection via the endpoints.

The front end is built in React and uses Axios to marry it to the endpoint, and that was working fine before.

Similar posts exist, but nothing quite like this

Error "MANIFEST.MF already exists in VFS" when creating new artifact

MANIFEST.MF (The system cannot find the path specified)

I really don't want to have to recreate the API again, but I am about out of other options and time.

Thank you in advance!

epicUsername
  • 611
  • 2
  • 8
  • 21
  • Your `UserRepository` interface extended another interface with many methods, and they will all need to be defined. My familiarity with Spring isn't great, but you likely wanted `UserRepository` to be an abstract class extending from something that already implemented `JpaRepository` for you (e.g. how there is `List` and `AbstractList` in the collections api). – Rogue Dec 14 '22 at 17:28
  • Yes. You need to extend JPA in the UserInterface to use what you want out of it, but it did not compel me to implement the 2-3 dozen methods that live in it when I do implement it. Usually, you might use one read, write, update and delete methods out of it in the controller, and it works; you don't need the Impl class specifically either. Removing it, doing a clean and update also results in nought. – epicUsername Dec 14 '22 at 17:42
  • Your class should be an interface extending CrudRepository. Spring will wire up the implementation at runtime - https://spring.io/guides/gs/accessing-data-jpa/ – Dan W Dec 14 '22 at 18:01
  • @epicUsername right, an interface does not need to implement abstract methods, since it is an "abstract" type itself (which is similar in this case to `public abstract class`). When you have a concrete class (e.g. `class MyClass`), then any abstract methods must be implemented. – Rogue Dec 14 '22 at 18:03
  • @DanW, I did consider that initially, and I've put CrudReposiyory back in, but to no effect. Rogue - indeed, but since I had none that need to be implemented, all I did in the Controller is create a repo object and pick the methods that I wanted out of it. – epicUsername Dec 14 '22 at 19:28
  • Ditch `UserRepositoryImpl` that isn't needed as it is a Spring Data JPA interface for which a dynamic repository will be created. You are also using Eclipse and Maven and my experience with that combination is not that good, they fight eachother on the classpath and for compiliation. One cleaning out stuff the other did and vice versa. – M. Deinum Dec 15 '22 at 06:59
  • @M.Deinum, I am using Spring Tools Suite 4 as my IDE, which integrates Maven... what would be a better solution in your opinion? E.g. VSCode, but I've been using that primarily for front-end stuff. – epicUsername Dec 15 '22 at 15:09

1 Answers1

0

In order to get the API to start:

First, it looks like the problem had to do with the fact that the project was on an network drive, which caused the initial errors; copying the project to a local C: drive directory got rid of them. It appears that whatever process Maven or Spring Boot uses to update references in this case doesn't capture folder redirection in the context of network drives; it might be because of a different proxy connection, but I can't be sure.

Then, you might an error that the API can't start, because it can't make a bean of the controller type. To resolve that, first check that your PK value is of the same type as the one in your database; in my case that was an integer type, since I am operating with MS SQL.

In my case, I also had to add the UserRepositoryImpl class file back in and implement all the methods from CrudRepository to clear the project of errors. The, do a clean and update, the project starts.

I still have the implementation of my repo methods in the controller, and the connection with the frontend is still broken, but at least I have an operational API again, without having to rebuild it.

Thanks again to everyone who commented!

epicUsername
  • 611
  • 2
  • 8
  • 21
  • as others have already pointed out, you don't have to implement UserRepositoryImpl provided that Maven has downloaded and resolved everything. So, this seems to be a Maven build issue. – dsp_user Dec 15 '22 at 12:03
  • It was a Maven build issue, indeed. It worked out after all. – epicUsername Feb 23 '23 at 03:58